# 萌新求带

P2669 [NOIP2015 普及组] 金币

1023196187hh @ 2021-10-27 19:55:02

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a,sum,day,mony,H,j;
    j = 1;
    sum = 0;
    mony = 0;
    day = 1;
    scanf("%d", &a);
    while(day <= a)
    {
        mony = mony + 1;
        j = 1;
        H = day;
        while(j<=H)
        {
            sum = sum + mony;
            day = day + 1;
            j = j + 1;
        }
    }
    printf("%d", sum);
}

卡住了,想不出来了,希望得到大佬的指点。。。


by j1ANGFeng @ 2021-10-27 20:07:29

@1023196187hh

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int a,sum,day,mony,H,j;
    j = 1;
    sum = 0;
    mony = 0;
    day = 0;
    scanf("%d", &a);
    while(day <= a)
    {
        mony = mony + 1;
        j = 1;
        H++;
        while(j<=H)
        {
            sum = sum + mony;
            day = day + 1;
            j = j + 1;
            if(day>=a){
                printf("%d",sum);
                return 0;
            }
        }
    }
    printf("%d", sum);
}

by 1023196187hh @ 2021-10-27 20:20:23

@jiangzimin6 谢了,老哥


by Yaokeming2011 @ 2021-11-21 13:53:18

/???


|