hn_zhangwb @ 2015-11-09 11:52:16
这道题源代码是什么
by xunzhen @ 2015-11-09 12:33:51
谁会告诉你
by hn_zhangwb @ 2015-11-09 12:37:12
????
by hn_zhangwb @ 2015-11-09 12:37:49
告诉我一下好吗?
by xunzhen @ 2015-11-10 20:12:13
可怜的419名,给你参考一下:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<windows.h>
int k,i,a,ans,x;
int main(){
freopen("coin.in","r",stdin);
freopen("coin.out","w",stdout);
scanf("%d",&k);
do{
i++;
if (x+i<=k) x+=i; else break;
a++;
}while(1);
ans=(k-x)*(a+1);
for (i=1;i<=a;i++)
ans+=i*i;
printf("%d\n",ans);
return 0;
}
by xunzhen @ 2015-11-10 20:24:22
忘记不要加文件了
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<windows.h>
int k,i,a,ans,x;
int main(){
scanf("%d",&k);
do{
i++;
if (x+i<=k) x+=i; else break;
a++;
}while(1);
ans=(k-x)*(a+1);
for (i=1;i<=a;i++)
ans+=i*i;
printf("%d\n",ans);
return 0;
}
by YPX1 @ 2015-12-08 20:53:00
#include<iostream>
#include<math.h>
using namespace std;
int n,s,s2,s3;
int main()
{
cin>>n;
while(s2<n)
{
s++;
s2+=s;
}
for (int i=1;i<=s;i++)
s3+=pow(i,2);
s3-=s*(s2-n);
cout<<s3;
}
by LIUBOWEN @ 2015-12-30 19:56:55
不用加文件!不用加文件!不用加文件!
(指这里)
by jerrywcy @ 2016-08-31 21:29:56
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int num_sum=0, days_sum=0, i=1, days;
cin >> days; // days = 8, 22
while (days_sum + i <= days)
{
days_sum += i;
num_sum +=i*i;
i++;
}
num_sum += (days - days_sum)*i;
cout << num_sum << endl;
return 0;
}