HELP!!0分!!

P2669 [NOIP2015 普及组] 金币

S_W_T @ 2018-08-03 20:35:39

#include<bits/stdc++.h>
using namespace std;

int main()
{
long long k=1,x=0,y=0,i=1,j,n,m=1;
cin>>k;
while(i<=k)
{
x=x+m; 
y++; 
if(y>=m)m++,y==0;
i++;
}
cout<<x;
return 0;
}

by Vokain @ 2018-08-03 20:40:23

while(i<=k)

会不会是天数问题


by S_W_T @ 2018-08-03 20:40:58

????


by intel_core @ 2018-08-03 20:41:22

y==0? y=0


by Vokain @ 2018-08-03 20:42:54

@Vokain 不好意思请无视我说的那句。。。==

by S_W_T @ 2018-08-03 20:43:41

@dongyancheng 3Q


by zybnxy @ 2018-08-03 20:44:14

是y=0不是y==0


by SundaShowa @ 2018-08-03 20:58:30

的确,第12行的

k==0

应改为

k=0

@血舞jerry


by pascalfans @ 2018-08-03 21:09:33

#include<bits/stdc++.h>
using namespace std;

int main()
{
long long k=1,x=0,y=0,i=1,j,n,m=1;
cin>>k;
while(i<=k)
{
x=x+m; 
y++; 
if(y>=m)m++,```
~~y==0;~~y=0;
```c++
i++;
}
cout<<x;
return 0;
}

by wxy_god @ 2018-09-16 13:20:58

@血舞jerry


by 小无人机 @ 2019-04-11 18:33:17

include<iostream>

using namespace std; int k; long long sum; int main() { cin>>k; int h=0; for(int i=1;;i++) { sum+=ii; h+=i; if(h>k) { sum-=(h-k)i; h=k; } if(h==k) { break; } } cout<<sum; return 0; }


|