先吐槽先吐槽!由於輸入太大,須要用fgets,讀n個字符或讀到回車終止。c++
char *fgets(char *str, int n, FILE *stream)
由於scanf模擬考試T了10+次。由於IO超時的題目都是樂色!(x數組
用數組存磁盤信息。\(char [1000][40960*2]\)不會爆。靜態數據區通常2G大小。spa
而後就是模擬。計算每一個詢問塊號的條帶號、單個磁盤條帶號、磁盤號。分狀況討論。code
%x小寫16進制,%X大寫。%d十,%o八,%b二。ip
#include <bits/stdc++.h> const int maxn = 1000; const int maxm = 40960; using namespace std; char disk[maxn+10][maxm*2+10]; int vis[maxn+10]; int len, got = 0; int main() { int n, s, l; scanf("%d%d%d", &n, &s, &l); memset(vis, 0, sizeof(vis)); for (int i = 1, x; i <= l; i++) { scanf("%d ", &x); vis[x] = 1; fgets(disk[x], maxm*2 + 10, stdin); if (!got) { len = strlen(disk[x]) / 8 / s - 1; got = 1; } } int m; scanf("%d", &m); while (m--) { int b; scanf("%d", &b); int stripe = b / s; int k = stripe / (n-1); int diskNum = (n - k%n + stripe % (n-1)) % n; if (k > len || (n-l >= 2 && !vis[diskNum])) { printf("-\n"); } else { int st = (k*s + b%s) * 8, en = st + 7; if (vis[diskNum]) { for (int i = st; i <= en; i++) printf("%c", disk[diskNum][i]); printf("\n"); } else { for (int i = st; i <= en; i++) { int ans = 0; for (int j = 0, tmp; j <= n-1; j++) { if (j != diskNum) { if (disk[j][i] >= '0' && disk[j][i] <= '9') { tmp = disk[j][i] - '0'; } else { tmp = disk[j][i] - 'A' + 10; } ans ^= tmp; } } printf("%X", ans); } printf("\n"); } } } return 0; }