/ Vijos / 题库 / 金币 /

题解

70 条题解

  • 5
    @ 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;
    }
    
    
    
  • 2
    @ 2017-10-28 16:50:11

    var
    k,i,n:longint;
    begin
    n:=0;
    read(k);
    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.

  • 1
    @ 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;
    }*

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

    水。。。。一次通过
    var
    i,a,b,n,q:longint;
    begin
    read(n);
    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.

  • 1
    @ 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;
    }
    
  • 1
    @ 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;
    }

  • 1
    @ 2018-02-13 15:23:17

    C#党都看过来啊!
    平均全部通过测评0.8S,平均占用内存12M。
    我写的还算是比较简洁易读的。
    觉得我写得好的记得点一下好评哦~!

    using System;
    using static System.Console;
    class Test{
        public static void Main(string[] args){
            int day = int.Parse(ReadLine()),coin = 0;
            for(int i = 1;;i++){
                day -= i;
                if(day <= 0){
                    coin += (i + day) * i;
                    break;
                }else{
                    coin += i * i;
                }
            }
            Write(coin.ToString());
        }
    }
    
  • 1
    @ 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;
    }

  • 1
    @ 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;
    }

  • 1
    @ 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;
    }
    
  • 1
    @ 2017-05-20 16:30:44

    so easy~

    var
      k, i, s:longint;
    begin
      read(k);
      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.
    
    
  • 0
    @ 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;
    }

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

    Pascal代码
    var
    n,k,i,m,s:longint;
    begin
    readln(n);
    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.

  • 0
    @ 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;
    }

  • 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;
    }

  • 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;
    }

  • 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;
    }

  • 0
    @ 2017-09-10 09:19:07

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    long long a=0,b=0,c=0,k,i,j;
    cin>>k;
    for(i=1;i<=100001;i++)
    for(j=1;j<=i;j++)
    {
    a++;
    b+=i;
    while(a==k)
    {
    cout<<b<<endl;
    return 0;

    }

    }
    }

  • 0
    @ 2017-08-28 22:23:26

    水的不能再水

  • 0
    @ 2017-08-23 13:19:44
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        long long n,tot=0;
        long long l=1,k=1;
        
        cin>>n;
        for (long long i=1;i<=n;i++)
        {
            if (l>k) l=1,k++;
            l++;
            tot += k;
        }
        cout<<tot;
    }
    

信息

ID
1974
难度
3
分类
模拟 点击显示
标签
递交数
2829
已通过
1335
通过率
47%
上传者