yuzhechuan @ 2017-10-28 09:18:53
var
i,x,n,j:longint;
ans:qword;
begin
readln(n);
ans:=0;
x:=0;
for i:=1 to 1000 do
for j:=1 to i do
begin
inc(x);
inc(ans,i);
if x=n then writeln(ans);
halt;
end;
end.
by awask @ 2017-10-29 11:11:11
c++:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int total=0,i,n,j=0,k=1;
cin>>n;
for(i=1;i<=n;i++)
{
j++;
total+=k;
if(k<=j) j=0,k++;
}
cout<<total;
return 0;
}
pas:
program coins;
var total,i,n,j,k:longint;
begin
total:=0;
j:=0;
k:=1;
readln(n);
for i:=1 to n do
begin
inc(j);
inc(total,k);
if k<=j then begin j:=0; inc(k); end;
end;
writeln(total);
end.
by awask @ 2017-10-29 11:12:21
你的循环一次就会half…………………………
by fondness_zzy @ 2017-11-07 18:47:17
这是我的Pascal代码(我也是P党)
var
n,m,i,j,k,s,x:longint;
begin
readln(n);
i:=1;
x:=1;
repeat
for j:=1 to x do
begin
s:=s+x;
inc(i);
if i>n then break;
end;
inc(x);
until i>n;
writeln(s);
end.
by fondness_zzy @ 2017-11-07 18:47:51
你的循环会炸