奇怪的错误求助

P3396 哈希冲突

代码如下: ```cpp #include <bits/stdc++.h> using namespace std; const int N = 150009,M = 409; int a[N],n,m,ans; int f[M][M],x,y; char opt; inline void read(int &x) { char ch = getchar(); int p = 1; x = 0; while(!isdigit(ch)) { if(ch == '-') p = -1; ch = getchar(); } while(isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } x *= p; } int main() { //freopen("C:\\Users\\lenovo\\Desktop\\P3396_3.in","r",stdin); //freopen("C:\\Users\\lenovo\\Desktop\\P3396_3.ans","w",stdout); read(n); read(m); for(int i = 1;i <= n;i++) { read(a[i]); for(int p = 1;p <= sqrt(n);p++) { f[p][i % p] += a[i]; } } while(m--) { scanf("%c",&opt); read(x); read(y); if(opt == 'A') { if(x * x <= n) { printf("%d\n",f[x][y]); }else { ans = 0; for(int i = y;i <= n;i += x) ans += a[i]; printf("%d\n",ans); } }else { for(int p = 1;p <= sqrt(n);p++) { f[p][x % p] += (y - a[x]); } a[x] = y; } } return 0; } ```
by TRZ_2007 @ 2021-02-16 14:20:39


Biller is a boker
by Bosun @ 2021-02-16 14:23:46


@[zbs2006](/user/127915) bosun 正常点……
by TRZ_2007 @ 2021-02-16 14:24:29


@[TRZ_2007](/user/86971) Terrier is a boker
by Bosun @ 2021-02-16 14:28:15


对拍程序也给一下,帮忙调一下吧…… code(对拍): ```cpp #include <bits/stdc++.h> using namespace std; int a[150009],b[150009]; int cont,N = 149999; int main() { freopen("C:\\Users\\lenovo\\Desktop\\P3396_3.ans","r",stdin); // read my answer for(int i = 1;i <= N;i++) scanf("%d",&a[i]); freopen("C:\\Users\\lenovo\\Desktop\\P3396_3.out","r",stdin); // read accpeted answer for(int i = 1;i <= N;i++) scanf("%d",&b[i]); for(int i = 1;i <= N;i++) { if(a[i] != b[i]) { printf("WA on %d: yours: %d ans: %d\n",i,a[i],b[i]); ++cont; } } if(!cont) puts("accpeted"); return 0; } ```
by TRZ_2007 @ 2021-02-16 14:34:25


错误找到了,此贴终结,但是随之而来的还会有一个疑问贴
by TRZ_2007 @ 2021-02-16 15:25:17


|