/ Vijos / 题库 / 金币 /

题解

74 条题解

  • 0
    @ 2015-11-24 17:43:14

    var j,k,n,m,s,t:longint;
    a:string;
    b:array[1..100000000]of longint;

    begin

    read(n);
    s:=1;
    for j:=1 to n do
    begin
    t:=j;
    while t<>0 do
    begin
    b[s]:=j; s:=s+1;
    t:=t-1;
    end;
    end;
    for j:=1 to n do m:=m+b[j];
    write(m);

    end.

  • 0
    @ 2015-11-15 10:15:37

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {

    long long int a,b,c,e,f,g;
    int d=0;
    cin>>a;
    while(1)

    {
    d++;
    c=(d*(d+1))/2;
    if(c>=a)
    {break; }
    }
    d=d-1;
    e=(2*a-d*(d+1))/2*(d+1);
    f=d*(d+1)*(2*d+1)/6;
    g=f+e;
    cout<<g<<endl;
    return 0;
    }

  • 0
    @ 2015-11-14 14:12:06

    无坑无难度~
    代码呈上:
    #include <iostream>
    #include <cmath>
    #include <cstring>

    using namespace std;

    main ()
    {
    long long int n; //保险起见~
    long long int t;
    long long int s;
    cin>>n;
    t=1;
    s=0;
    while(n>=t)
    {
    n-=t;
    s+=t*t;
    t++;
    }
    s+=n*t;
    cout<<s;
    }

  • 0
    @ 2015-11-12 22:00:39

    近半年写过的唯一一个少于80行的程序

    #include <stdio.h>
    int main(){
    int i, day, coin = 0;
    scanf("%d", &day);
    for(i=1; (1+i)*i/2<=day; i++)
    coin += i*i;
    coin += (day-i*(i-1)/2)*i;
    printf("%d\n", coin);
    return 0;
    }

  • 0
    @ 2015-11-09 14:45:44

    #include<iostream>
    using namespace std;

    int main(){
    int k,ans=0,now=1,c1=0;
    cin>>k;
    for(int i=1;i<=k;i++){
    ans+=now;
    ++c1;
    if(now==c1) {
    c1=0;
    now++;
    }
    }
    cout<<ans;
    return 0;
    }

  • 0
    @ 2015-11-09 08:57:42

    真想回到普及组。。
    模拟。。。。。。。
    var
    x,ans,n,i,m:longint;
    begin
    readln(n);
    x:=0; i:=0; m:=1;
    while x<n do
    begin
    ans:=ans+m;
    inc(x);
    inc(i);
    if i=m then
    begin
    inc(m);
    i:=0;
    end;
    end;
    writeln(ans);
    end.

  • 0
    @ 2015-11-09 08:35:49

    为什么井号和星号发了显示不出来

  • 0
    @ 2015-11-09 08:34:51

    **

  • 0
    @ 2015-11-09 08:34:39

  • 0
    @ 2015-11-09 08:34:04

    #include<algorithm>
    #include<cstring>
    #include<iostream>
    using namespace std;
    //ifstream fin("coin.in");
    //ofstream fout("coin.out");
    int n,i=0,ct,net;

    int main()
    {
    cin>>n;
    while(n>0)
    {
    i++;
    ct+=i*i;
    n=n-i;
    net=i;

    }
    if(n<0)
    {
    ct=ct-((0-n)*i);
    }
    cout<<ct;

    return 0;
    }

  • 0
    @ 2015-11-09 08:19:57

    直接把考试的传上来了,^_^。

  • 0
    @ 2015-11-09 08:17:27

    #include<algorithm>
    #include<cstring>
    #include<fstream>
    using namespace std;
    ifstream fin("coin.in");
    ofstream fout("coin.out");
    int n,i=0,ct,net;

    int main()
    {
    fin>>n;
    while(n>0)
    {
    i++;
    ct+=i*i;
    n=n-i;
    net=i;

    }
    //fout<<ct;
    if(n<0)
    {
    ct=ct-((0-n)*i);
    }
    fout<<ct;

    return 0;
    }

  • -1
    @ 2017-10-20 09:07:35

    var
    k,n,ans:longint;
    begin
    readln(k);
    ans:=0;
    n:=1;
    while k>=n do
    begin
    ans:=ans+n*n;
    k:=k-n;
    inc(n);
    end;
    ans:=ans+k*n;
    writeln(ans);
    end.

  • -1
    @ 2016-10-18 15:36:25

    #include <iostream>
    using namespace std;

    int main()
    {
    int i,j,sum=0,num=0,a=1,in;
    cin>>in;
    for(i=1;;i++)
    {
    for(j=1;j<=i;j++)
    {
    sum+=i;
    num++;
    if(num==in) {a=0;break;}
    }
    if(a==0) break;
    }
    cout<<sum;

    return 0;
    }

信息

ID
1974
难度
3
分类
模拟 点击显示
标签
递交数
2947
已通过
1418
通过率
48%
被复制
32
上传者