本文章由 WyOJ Shojo 从洛谷专栏拉取,原发布时间为 2021-04-04 12:39:39
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;
}

鲁ICP备2025150228号