#37216: C++


11131039@stu.tshs.tp.edu.tw (二孝25林孟希)

學校 : 不指定學校
編號 : 201083
來源 : [125.228.248.38]
最後登入時間 :
2024-04-17 14:50:03
d881. 作業苦多 -- CSDC | From: [36.225.121.18] | 發表日期 : 2023-08-26 12:29

#include <bits/stdc++.h>
using namespace std;
int an(int n,int d)
{
    if(n==1)
    {
        return 1;
    }
    else
    {
        return an(n-1,d)+1+(n-2)*d;   
    }
}

int main()
{
    int d;
    while(cin>>d)
    {
        int sum=0;
        for(int i=1;i<=50;i++)
        {
            sum+=an(i,d);
        }
        cout<<sum<<endl;   
    }
}

 
ZeroJudge Forum