Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
76757 彭林江 数列求和 C++ Accepted 1 MS 272 KB 276 2024-06-02 17:24:10

Tests(5/5):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; long long a[n+1]; a[1] = 1; for(int i = 2; i <= n; i++){ a[i] = a[i-1] * 2; } long long sum = 0; for(int i = 1; i <= n; i++){ sum += a[i]; } cout << sum; return 0; }