思路在后
2025-04-13 11:27:32
发布于:四川
4阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
long long a[60] = {}, cnt = 5;
a[1] = 2;
for(int i = 2; i <= n; i++) {
a[i] = a[i - 1] + cnt;
cnt += 4;
}
cout << a[n];
return 0;
}
/*
| i | a[i] |
| : | : |
| 1 | 2 |
| 2 | 7 |
| 3 | 16 |
| 4 | 29 |
*/
```cpp
```cpp
全部评论 1
ASDFDASFDSFSFDASFSDA
2025-04-13 来自 四川
0
有帮助,赞一个