Konnyaku_q @ 2022-03-15 17:17:37
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int c,b,a=0;
cin>>c;
for(b=1;c-b>=0;c-=b++)
{
c+=b*b;
}
cout<<c+a*b<<endl;
return 0;
}
by Konnyaku_k @ 2022-03-15 17:24:34
b没有变啊
by _wzcxx @ 2022-03-15 17:26:39
你是不是需要一个判断
by Konnyaku_q @ 2022-03-15 17:27:18
#include<iostream>
using namespace std;
int main()
{
int k,n=0,s=0,a=0,l=1;
cin>>k;
for(int i=0;;i++)
{
for(int j=1;j<=i;j++)
{
if(n==k)
{
cout<<s<<endl;
}
else
{
a+=i;
s++;
}
}
i++;
}
return 0;
}
by Konnyaku_k @ 2022-03-15 17:30:07
@屌德斯 都没有break啊!
by Konnyaku_q @ 2022-03-15 17:32:44
#include<iostream>
using namespace std;
int main()
{
int k,n=0,s=0,a=0,l=1;
cin>>k;
for(int i=0;;i++)
{
if(n==k)
{
cout<<s<<endl;
return 0;
}
else
{
a+=i;
s++;
}
i++;
}
}
by Konnyaku_k @ 2022-03-15 17:34:00
i为啥加两扁啊?
by _wzcxx @ 2022-03-15 17:35:47
@屌德斯 这代码过了
#include<iostream>
using namespace std;
int main()
{
int k,n=1,s=0,a=1;
cin>>k;
for(int i=1;i<=k;i++)
{
s+=n;
if(i==a)
{
n++;
a+=n;
}
}
cout<<s<<endl;
return 0;
}
by siyu0816 @ 2022-09-13 21:20:47
#include <iostream>
using namespace std;
int n,q,c,s;
int main()
{
cin>>n;
c=q=1;
for(int i=1;i<=n;i++)
{
s=s+c;
q--;
if(q==0)
{
c++;
q=c;
}
}
cout<<s;
return 0;
}
by siyu0816 @ 2022-09-13 21:21:40
过了
by Susara @ 2022-09-27 21:40:23
int day = 0,cnt = 1,n,sum = 0; //cnt存储每天金币数量,sum存储金币的总和 cin>>n; while(n--){ sum+=cnt; day++; if(day == cnt){ cnt++; day = 0; } } cout<<sum;
//这样更好一点吧