system("pause");是什么情况
难道是我看错了
by little_gift @ 2017-10-19 19:14:49
# 你直接输出试试?
by SofanHe @ 2017-10-19 19:16:35
直接输出不行才改成这样的
by mylsl @ 2017-10-19 19:30:47
system(pause)在测试的时候删掉了,除了这三个点都A了
by mylsl @ 2017-10-19 19:32:55
发现a重复定义了:(
不过改过来还是不对
by mylsl @ 2017-10-19 19:48:28
同问1,3,4too many or too few lines ,而且测试数据太大下载不了。。。
@ [多功能的荀彧](/space/show?uid=43931) @[多功能的荀彧](/space/show?uid=43931)
改成了scanf,printf也不行啊
```cpp
#include <iostream>
#include <cstdio>
using namespace std;
int a[500000+5],c[500000+5];
int n;
inline int lowbit(int x)
{
return x&(-x);
}
inline int sum(int k)
{
int ans=0;
while(k>=1) {
ans+=c[k];
k-=lowbit(k);
}
return ans;
}
inline int update(int pos,int k)
{
while(pos<=n) {
c[pos]+=k;
pos+=lowbit(pos);
}
}
inline int sumbet(int l,int r)
{
return (sum(r)-sum(l-1));
}
int main()
{
int m;
// cin>>n>>m;
scanf("%d%d",&n,&m);
int temp,t1,t2,t3;
for(int i=1;i<=n;i++){
// cin>>temp;
scanf("%d",&temp);
update(i,temp);
}
for(int i=1; i<=n; i++) {
scanf("%d",&temp);
if(temp==1) {
// cin>>t1>>t2;
scanf("%d%d",&t1,&t2);
update(t1,t2);
}
if(temp==2) {
// cin>>t1>>t2;
scanf("%d%d",&t1,&t2);
// cout<<sumbet(t1,t2)<<endl;
printf("%d\n",sumbet(t1,t2));
}
}
}
```
by zhshh @ 2017-10-20 13:21:47
@[zhshh](/space/show?uid=58321) 很尴尬。。。n个输入数据,m次操作。。。然而我两个for都是n.....
by zhshh @ 2017-10-20 14:19:50
@[Robertlsl](/space/show?uid=47975) 还是楼上看出了问题,你也都是用的n啊
by SofanHe @ 2017-10-20 16:45:11
谢谢各位指导,改完之后就A了:)
by mylsl @ 2017-10-20 23:33:41