求助0分,自测全对

P1483 序列变换

这个代码能70分,剩3个点T了 ```cpp #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int a[N]; int main() { int n, T, pos, x, y; cin >> n >> T; for (int i = 1; i <= n; i++)cin >> a[i]; while (T--) { cin >> pos >> x; if (pos == 1) { cin >> y; for (int k = 1; k * x <= n; k++)a[k * x] += y; } else cout << a[x] << endl; } return 0; } ```
by Manipula @ 2023-09-09 21:46:45


@[Manipula](/user/963247) 那请问我的做法哪里错了(全WA没超时
by Cstdio_Rabbit @ 2023-09-09 21:55:29


$l$ 从2枚举吧
by Manipula @ 2023-09-09 21:57:21


@[Manipula](/user/963247) 那1的也应该算进去啊
by Cstdio_Rabbit @ 2023-09-09 21:59:26


``` int now=a[j],maxn=sqrt(a[j]); ``` 不对 应该把 $a_j$ 改成 $j$。
by __pig__ @ 2023-09-09 22:02:20


@[CstdioFrog](/user/235901) 我的代码~~刚A的~~ ```cpp #include<bits/stdc++.h> #define int long long using namespace std; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){f=ch=='-'?-f:f;ch=getchar();} while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();} return f*x; } const int N=1e6+5; int n,sum[N],a[N],op,x,y,m,ans; signed main(){ n=read();m=read(); for(int i=1;i<=n;++i)a[i]=read(); while(m--){ op=read();x=read(); if(op==1)sum[x]+=read(); else{ ans=a[x]; for(int i=1;i*i<=x;++i){ if(x%i==0){ ans+=sum[i]; if(i*i!=x)ans+=sum[x/i]; } }printf("%lld\n",ans); } } } ```
by __pig__ @ 2023-09-09 22:03:00


@[CstdioFrog](/user/235901) 最后+$a_j$
by __pig__ @ 2023-09-09 22:03:37


@[oier01](/user/721959) 谢谢~~在您说之前几秒我刚刚发现~~
by Cstdio_Rabbit @ 2023-09-09 22:04:06


@[oier01](/user/721959) 过了,谢谢orz
by Manipula @ 2023-09-09 22:07:02


|