hzszchengzhekai @ 2017-09-03 18:27:28
var
k,a,i,j,t,b:longint;
begin
read(k);
i:=1;
a:=0;
j:=0;
t:=1;
repeat
a:=i*i+a;
j:=j+t;
inc(t);
inc(i);
until j>=k;
b:=i*(j-k);
a:=a-b;
write(a);
end.
by 蒻得不行 @ 2017-09-03 19:36:43
c++路过。。
by huanglth @ 2017-09-16 14:49:00
var
n,day,ans,now:longint;
begin
assign(input,'p2669.in'); reset(input);
assign(output,'p2669.out'); rewrite(output);
ans:=0; day:=1; now:=0;
readln(n);
while now<n do
begin
ans:=ans+day*day;
now:=now+day;
day:=day+1;
end;
if now>n then ans:=ans-(now-n)*(day-1);
writeln(ans);
close(input);
close(output);
end.
by 夢·壹生所愛 @ 2017-10-05 19:36:49
#include<cstdio>
using namespace std;
int main()
{
int n,cnt=0,s=0;
scanf("%d",&n);
for(int j=1;;j++)
{
for(int i=1;i<=j;i++)
{
s+=j;
cnt++;
if(cnt==n)
{
printf("%d",s);
return 0;
}
}
}
}