AT1198_100 @ 2020-04-01 15:09:44
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
int n,x;
cin>>x;
n=sqrt(2*x+1/4)-1/2;
cout<<(n*(n+1)*(2*n+1))/6;
return 0;
}
为什么我只有40分?求助大佬。。。
by Franka @ 2020-04-01 15:10:30
模拟不行吗?
by Chanter @ 2020-04-01 15:12:44
@winterzxy 精度不够
by Chanter @ 2020-04-01 15:13:08
用int类型算小数珂海星
by AT1198_100 @ 2020-04-01 15:14:21
@空与灵之白 那要开多少啊,long long吗?
by Chanter @ 2020-04-01 15:16:09
@winterzxy double类型
by AT1198_100 @ 2020-04-01 15:18:05
@空与灵之白 我开了double。。。然后变成了0分。。。
by Chanter @ 2020-04-01 15:22:39
@winterzxy 谔谔???
by gongyr @ 2020-04-01 15:24:11
强制转换?
by gongyr @ 2020-04-01 15:24:24
@winterzxy
by Chanter @ 2020-04-01 15:26:01
诶对哦(