/ Vijos / 题库 / 金币 /

73 条题解

• @ 2017-11-07 14:40:29
``````#include<iostream>
using namespace std;
int main()
{
int n,t=1;
cin>>n;
int money=1;
int day=1;
int sum=0;
for(int i=1;i<=n;i++)
{

if(day==0)
{
t++;
day=t;
money=day;
}
sum+=money;
day--;

}
cout<<sum;
}

``````
• @ 2017-10-28 16:50:11

var
k,i,n:longint;
begin
n:=0;
i:=1;
while k> i do
begin
n:=i*i+ n;
k:=k-i;
i:=i+1;
end;
if(k> 0) then n := n+i*k;
write(n);
end.

• @ 2023-07-07 14:07:21
``````#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
int main ()
{

int n,s=0,t=0;
cin>>n;
for(int i=1;;i++)
{
for(int j=1;j<=i;j++){
s+=i;
t++;
if(t==n)
{
cout<<s;
return 0;
}
}
}

}
``````
• @ 2021-08-29 16:46:21
``````#include<bits/stdc++.h>
using namespace std;

int main()
{
int K,N,coin=0;
scanf("%d",&K);
for(N=1;K-N>=0;K-=N++)
coin+=N*N;
printf("%d\n",coin+K*N);
return 0;
}
``````
• @ 2020-09-22 14:55:24
``````#include <cmath>
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;
int ans = 0;
for (int i = 1;; i++)
{
for (int j = 1; j <= i; j++)
{
ans += i;
if (--n == 0)
{
return cout << ans, 0;
}
}
}
}
``````
• @ 2018-09-02 11:48:55

***#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k=1;
int gold=1;
int day=1;
int ans=0;
cin>>n;
for(int i=1;i<=n;i++){
if(day==0){
k++;
day=k;
gold=day;
}
ans+=gold;
day--;

}
cout<<ans;
return 0;
}*

• @ 2018-08-01 22:21:40

水。。。。一次通过
var
i,a,b,n,q:longint;
begin
i:=0;
repeat
a:=0;i:=i+1;
repeat
b:=b+1;
q:=q+i;
a:=a+1;
until (a=i)or(b=n);
until b>=n;
writeln(q);
end.

• @ 2018-08-01 22:23:12

哈哈哈

• @ 2018-07-25 20:55:18

好水的题...
代码比较丑，
见谅！

``````#include <cstdio>
using namespace std;
int main() {
int k,ans=0,j=1,n=0;
scanf("%d",&k);
for (int i=1;i<=k;i++) {
if (n>=j) {
j++;
n=0;
}
ans+=j;
n++;
}
printf("%d",ans);
return 0;
}
``````
• @ 2018-06-21 11:59:41

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int k, days = 1, gold = 0;
cin>>k;
while(k > 1)
{
int i;
for(i = 1; i <= days; i++)
{
if(k == 0)
break;
gold+=days;
k--;
}
days++;
}
cout<<gold<<endl;
return 0;
}

• @ 2017-11-15 15:31:14

无循环

#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
int k, n1, sum;

cin>>k;

n1 = floor((sqrt(8*k+1)-1)/2);

sum = (n1*(n1+1)*(2*n1+1)) / 6 + (k-n1*(n1+1)/2)*(n1+1);

cout<<sum;
}

• @ 2017-09-21 21:10:26

#include<iostream>
using namespace std;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int k,i,j,ans=0,a=0;
cin>>k;
for(i=1;i<k;i++)
for(j=1;j<=i;j++)
{
ans+=i;
a++;
if(a==k)
{
cout<<ans;
return 0;
}
}
cout<<ans;
return 0;
}

• @ 2017-08-22 02:32:56

so water

``````#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
long long a=1,b=1,n,i,money=0;
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
if(i>b)
{
a++;
b=b+a;
}
money=money+a;
}
printf("%lld",money);
return 0;
}
``````
• @ 2017-05-20 16:30:44

so easy~

``````var
k, i, s:longint;
begin
i:=1;
s:=0;
while k>=i do begin
dec(k, i);
inc(s, sqr(i));
inc(i)
end;
inc(s, i*k);
write(s)
end.

``````
• @ 2020-05-22 20:56:45
``````#include <bits/stdc++.h>
using namespace std;
int money;
int main()
{
//金币
int K,day,i=1;
scanf("%d",&K);
while(money<K)
{
day+=i*i;
money+=i;
i++;
}
if (money==K) printf("%d",day);
else
{
day-=(money-K)*(i-1);
printf("%d",day);
}
}
``````
• @ 2018-11-07 14:26:19

#include<bits/stdc++.h>
using namespace std;
int main()
{
int day,i,j,sum=0,s=0;
cin>>day;
for(i=1;s<day;i++)
s+=i;
for(j=1;j<i-1;j++)
sum=j*j+sum;
sum+=(i-1)*(day-s+i-1);
cout<<sum;
return 0;
}

• @ 2018-11-04 11:13:09

Pascal代码
var
n,k,i,m,s:longint;
begin
k:=1;
for i:=1 to n do
begin
s:=s+k;
inc(m);
if m=k then
begin
m:=0;
inc(k);
end;
end;
write(s);
end.

• @ 2018-08-30 11:28:13

#include <stdio.h>
using namespace std;
int main()
{
int k,ans=0,b;
scanf("%d",&k);
int a=k;
for(int i=1;i<=a;i++)
{
if(k-i>=0)
{
k-=i;
ans=ans+i*i;;
}
else
{
b=i;
i=a+1;
}
}
ans=ans+b*k;
printf("%d",ans);
return 0;
}

• @ 2017-10-04 00:14:21

公式无敌。
#include <iostream>
using namespace std;

int k;
int temp=0;

int main(){
cin>>k;
int i=0;
while((i*(i+1)/2)<k){
i++;
}i--;
temp+=(k-(i*(i+1)/2))*(i+1);
temp+=i*(i+1)*(2*i+1)/6;
cout<<temp;
return 0;
}

• @ 2017-09-12 21:52:54

#include <stdio.h>

int main(){
int k, i, j,t=0, sum=0;
int m[10001] = { 0 };
scanf("%d", &k);
for (i = 1; i <= k; i++){
for (j = 1; j <= i; j++){
if (t==k){
break;
}
else{
++t;
m[t] = i;
}

}
sum += m[i];
}
printf("%d\n", sum);
return 0;
}

• @ 2017-09-10 09:34:36

c++拿走不谢

#include<iostream>
using namespace std;
int main()
{
int ans=0,n;
int tian=1,k=1;
cin>>n;
for(int i=0;i<n;i++)
{
for(;tian>k;k++) tian=1;
tian++;
ans+=k;
}
cout<<ans;
return 0;
}

ID
1974

3

2942

1414

48%

31