0
已解决
王文博
缔造者之神
缔造者之神
#include <bits/stdc++.h>
using namespace std;
int main()
{
int d,tianshu_1,tianshu_2=0,tianshu_3=0;
long long qianshu_1,qianshu_2=0;
cin>>d;
flag:
tianshu_2++;
for(int i=1;i<=tianshu_2;i++)
{
tianshu_3+=i;
}
tianshu_1=d-tianshu_3;
tianshu_3=0;
if(tianshu_1<0)
{
qianshu_1=pow(tianshu_2,2)-tianshu_2*(1-tianshu_1);
qianshu_2+=qianshu_1;
}
else if(tianshu_1==0)
{
qianshu_1=pow(tianshu_2,2);
qianshu_2+=qianshu_1;
}
else
{
qianshu_1=pow(tianshu_2,2);
qianshu_2+=qianshu_1;
goto flag;
}
cout<<qianshu_2;
return 0;
}
/***************此代码为错误代码,只有42分,请各位大神们指教!
谢谢!!!!若能改正错误代码,我感激万分!!
***************/
这是我的错误的地方,4,5,6,7测试点错误,42分
望大神赐教!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
0
已采纳
李素妍
新手天翼
新手天翼
- int x,d=0,he=0,n=1;
- cin>>x;
- while(d+n<=x){
- d=d+n;
- he=he+n*n;
- n++;
- }
- he=he+(x-d)*n;
- cout<<he<<endl;
- 我冒死发整段代码
0
0
0