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 化身灵蝶子 @ 2020-05-01 16:41:35
# include <stdio.h>
int main()
{
int i, j, k,t=0,x=0,coin=0;
int a[100000];
scanf_s("%d", &k);
for (i =0; i <= 200; i++)
{
j = i;
for (j; j > 0; j--)
{
a[t] = i;
t++;
}
}
for (x = 0; x < k; x++)
{
coin += a[x];
}
printf("%d", coin);
return 0;
}