那里没过呢

P1031 [NOIP2002 提高组] 均分纸牌

希望更丰富的展现?使用Markdown
by _Felix @ 2019-04-04 18:04:50


```cpp #include<bits/stdc++.h> using namespace std; int main() { int a[100]={0},b[100]={0}; int n,d=0,k=0,m=0; cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; k+=a[i]; d=k/n; b[i]=a[i]-d; } for(int i=1;i<n;i++) { if(b[i+1]!=0) { b[i+1]=b[i]+b[i+1]; m++; } if(b[i]==0)continue; } cout<<m; return 0; } ``` 都是因为你的排版有问题,才很少有人回答你
by GusyNight @ 2019-04-04 18:06:47


不过,我还是回答你一下吧~~~ = ***谁叫我那么善良呢~~~*** ```cpp #include<bits/stdc++.h> #define TP int #define Max 10009 using namespace std; inline TP read(){ char c=getchar(); TP x=0; bool f=0; while(!isdigit(c))f^=!(c^45),c=getchar(); while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar(); if(f)x=-x;return x; } int a=read(),p=0,ans=0,q[Max]; int main(){ for(int i=0;i<a;i++){ q[i]=read(); p+=q[i]; } p/=a; for(int i=0;i<a;i++){ q[i]-=p; } for(int i=0;i<a;i++){ if(q[i]==0){ continue; } q[i+1]+=q[i]; ans++; } cout<<ans; return 0; }
by GusyNight @ 2019-04-04 18:09:02


应该是方法不对
by GusyNight @ 2019-04-04 18:09:33


@[如鱼得水](/space/show?uid=166463) 听见了吗
by GusyNight @ 2019-04-04 18:09:46


@[缘,为何物?](/space/show?uid=191132) "回答"和贴代码性质完全不同好吗...
by aminoas @ 2019-04-04 18:11:26


@[2018J1605](/space/show?uid=143834) 好吧,但只要理解了思路,下次会写,也都一样了
by GusyNight @ 2019-04-04 18:14:30


@[缘,为何物?](/space/show?uid=191132) 但是你要指出他是哪里错了啊 ~~有时别人和你用的是不同的算法~~
by aminoas @ 2019-04-04 18:16:04


.......
by GusyNight @ 2019-04-04 18:16:25


是啊,错在哪里了?
by 如鱼得水 @ 2019-04-04 18:40:40


| 下一页