UVA13221

· · 题解

1 1
2 3
3 7
4 11
5 17
6 23
7 31

规律不难发现,递推式为:

\frac{(n+1)^2}{2}-1

最后献上我的代码:


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll n;
    while(cin>>n) {
        ll p=(n+1)*(n+1)/2-1;
        cout<<p;
        cout<<endl;
    }
    return 0;
}