1 条题解

  • 0
    @ 2024-12-5 18:24:10

    C++ :

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

    Python :

    a=int(input())
    if a>=1 and a<=10000:
        coins=0
        days=0
        daystrue=0
        tof=1
        while daystrue<=a:
            days+=1
            for i in range(days):
                if daystrue<a:
                    coins+=days
                    daystrue+=1
                else:
                    tof=0
                    break
            if tof==0:
                break
        print(coins)
    
    
    • 1

    信息

    ID
    9193
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者