这题意思讲得不好

P1181 数列分段 Section I

操,我被坑也~
by 卟离 @ 2015-11-04 18:00:44


```cpp #include<cstdio> int n,m,x=0,y,tot=1,a[100000]; int main(void){ scanf("%d%d",&n,&m); for(int i=0;i<n;i+=1){ scanf("%d",&y); x+=y; if(x>m) x=y,tot+=1; } printf("%d",tot); } ```
by hxr20041011 @ 2016-06-18 11:09:46


这题简直是道阅读理解啊
by CR_Raphael @ 2016-08-04 15:59:39


简单啊
by 李紫浩 @ 2016-11-04 23:05:42


太简单了,附上代码供被抄袭 ```cpp #include<iostream> using namespace std; int a[100000]={0}; int main() { int n,m,b,ans=0, cin>>n>>m; for(int x=0;i<n;x++) { cin>>b; x+=b; if(x>m) { x=b; ++ans; }; } cout <<ans; } ```
by bestcow @ 2017-05-14 10:32:14


等下,好像跟楼上撞了。。。。。。 (有点尴尬不要说)
by bestcow @ 2017-05-14 10:32:52


```cpp #include<iostream> using namespace std; int a[100000]={0}; int main() { int n,m,b,ans=0; cin>>n>>m; for(int x=0;x<n;x++) { cin>>b; x+=b; if(x>m) { x=b; ++ans; }; } cout <<ans; } ``` 刚刚卡机了,这是正确代码 ```cpp #include<iostream> using namespace std; int a[100000]={0}; int main() { int n,m,b,ans=0; cin>>n>>m; for(int x=0;x<n;x++) { cin>>b; x+=b; if(x>m) { x=b; ++ans; }; } cout <<ans; } ```
by bestcow @ 2017-05-14 10:35:13


又错了,这里x=b,是x=x+b
by bestcow @ 2017-05-14 10:37:33


x=b这条去了万事大吉
by bestcow @ 2017-05-14 10:39:07


|