/ Vijos / 题库 / 金币 /

题解

74 条题解

  • 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;
    }
    
  • 0
    @ 2017-07-30 22:49:45

    #include <iostream>
    using namespace std;
    int main()
    {
    int k,a,b=0;
    int c=0;
    cin>>k;
    for(a=1;b<=k;a++)
    {
    b=b+a;
    c=c+a*a;
    }
    a=a-1;
    c=c-(b-k)*a;
    cout<<c;
    return 0;
    }

  • 0
    @ 2017-07-08 20:26:45
    //大佬都在用数学 萌新就直接模拟了lol
    #include <cstdio>
    #include <iostream>
    
    using namespace std;
    
    int main(){
        int k;
        cin >> k;
        int sum = 0;
        int cur = 1;
        int remain = 1;
        for (int i = 1; i <= k; i++){
            if (remain == 0) remain = ++cur;
            sum += cur;
            remain--;
        }
        cout << sum << endl;
        return 0;
    }
    
  • 0
    @ 2017-06-21 21:06:16

    3q22321321321

  • 0
    @ 2017-06-21 21:05:53

    asdasdasdasdas

  • 0
    @ 2016-10-06 12:20:41

    pascal代码,只用了一重循环,大概是O(n)吧!!
    var
    n,ans,k,day:longint;
    begin
    readln(n);
    ans:=1;
    repeat
    k:=k+ans*ans;
    day:=day+ans;
    ans:=ans+1;
    until day>=n;
    k:=k-(day-n)*(ans-1);
    writeln(k);
    end.

  • 0
    @ 2016-09-28 14:09:02

    先自己加加,找规律就做了。没多想纯数学

    #include<iostream>
    #include<cmath>
    using namespace std;
    int main(){
    int m,k,i,a=0;
    cin>>k;
    for(i=1;(0.5*i+0.5*i*i)<=k;i++){
    a+=i*i;
    m=i;
    }
    if(k==(0.5*i+0.5*i*i)){
    cout<<a;
    return 0;
    }
    else {
    a+=(k-(0.5*m+0.5*m*m))*(m+1);
    }
    cout<<a;
    return 0;
    }

  • 0
    @ 2016-09-25 12:30:49

    高中数列方法,需要很高的逻辑能力……你们看不懂算了
    program P1974;
    var
    i,n,j:integer;
    a:array[1..10000] of longint;
    ans:longint;
    begin
    read(n);
    for i:=1 to n do
    a[i]:=(i*i+i) div 2;
    i:=0;
    repeat
    i:=i+1;
    until n<=a[i];
    ans:=0;
    j:=0;
    repeat
    j:=j+1;
    ans:=ans+j*j;
    until j=i-1;
    ans:=ans+(n-a[i-1])*i;
    writeln(ans);
    end.

  • 0
    @ 2016-08-24 21:20:55

    楼下等人代码好长,膜拜……
    c++
    #include<iostream>
    using namespace std;
    int main()
    {
    int n;
    cin>>n;
    int i=0,ans=0;
    while(++i&&i<=n)
    {
    n-=i;
    ans=ans+i*i;
    }
    ans=ans+i*n;
    cout<<ans;
    return 0;
    }

  • 0
    @ 2016-08-23 18:33:00

    AC超简易
    #include<bits/stdc++.h>
    using namespace std;
    int a,ans;
    int coin(int x)
    {
    int t,i;
    if(a==0)
    {
    cout<<ans<<endl;
    return 0;
    }
    x++;
    t=x;
    if(a>=t)
    {
    a=a-t;
    for(i=1;i<=t;i++)
    ans=ans+x;
    coin(x);
    }
    else if(t>a)
    {
    for(i=1;i<=a;i++)
    ans=ans+x;
    a=0;
    coin(x);
    }
    }
    int main()
    {
    cin>>a;
    coin(0);
    }

  • 0
    @ 2016-08-23 10:22:23

    var k,i,s,d:longint;
    begin
    readln(k);
    s:=0;d:=0;i:=0;
    repeat inc(i);
    d:=d+i;
    s:=s+i*i;
    until d>=k;
    d:=d-k;
    s:=s-d*i;
    writeln(s);
    end.

  • 0
    @ 2016-08-16 09:54:07

    #include <cstdio>
    #include <cstdlib>

    #define a

    #ifndef a
    int main() {
    long long k, n = 1, tot = 0, ans = 0;
    scanf("%lld", &k);
    while ((tot + n) <= k) {
    ans += n*n, tot += n++;
    }
    ans += (k - tot)*n;
    printf("%lld", ans);
    return 0;
    }
    #else
    int main(){
    long long k,n=1,tot=0,ans=0;
    scanf("%lld",&k);
    while((tot+n)<=k){
    for(int i =1;i<=n*n;i++,ans++);
    for(int i =1;i<=n;i++,tot++);
    n++;
    }
    for(int i =1;i<=(k-tot)*n;i++,ans++);
    printf("%lld",ans);
    return 0;
    }
    #endif
    上面的程序
    测试数据 #0: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #6: Accepted, time = 15 ms, mem = 508 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    Accepted, time = 15 ms, mem = 508 KiB, score = 100
    下面的程序
    测试数据 #0: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 508 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 504 KiB, score = 10
    Accepted, time = 0 ms, mem = 508 KiB, score = 100

  • 0
    @ 2016-08-14 17:44:45
    #include<cstdio>
    int main()
    {
        int k,t,i=1,j=1,ans=0;
        scanf("%d",&k);
        for(t=1;t<=k;t++)
        {
            ans+=j;
            i--;
            if(i==0)
            {
                j++;
                i=j;
            }
        }
        printf("%d",ans);
        return 0;
    }
    
  • 0
    @ 2016-08-14 11:23:47

    这道题就是用来放松心情的
    ```c++
    #include<iostream>
    #include<cstdio>
    using namespace std;

    const int maxn = 10000 + 10;

    int f[maxn];
    void init () {
    int cur = 0;
    for (int i = 1; cur < maxn; i++) {
    for (int j = 0; j < i; j++) {
    if (++cur >= maxn) break;
    f[cur] = f[cur-1]+i;
    }
    }
    }

    int main () {
    init();
    int k; cin >> k;
    cout << f[k];
    }
    ```

  • 0
    @ 2016-08-13 20:41:16

    #include<stdio.h>
    int main()
    {
    int k;
    scanf("%d",&k);
    int sum = 0;
    int tmp = 1;
    int tmp_ = 1;
    for(int i = 1;i <= k; i++)
    {
    for(int j = 1;j <= tmp; j++)
    {
    if(tmp_ <= k)
    {
    sum += tmp;
    tmp_++;
    }
    }
    tmp++;
    if(tmp_ > k)
    break;
    }
    printf("%d",sum);
    }

  • 0
    @ 2016-08-03 14:49:50

    好水
    pascal
    var
    a,i,j,n,t:longint;
    begin
    readln(n);
    for i:=1 to n do
    for j:=1 to i do
    begin
    inc(a,i);
    inc(t);
    if t=n then
    begin
    writeln(a);
    halt;
    end;
    end;
    end.

  • 0
    @ 2016-06-25 11:12:06

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

信息

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