Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
76752 胡盛哲 数列求和 C++ Accepted 0 MS 268 KB 271 2024-06-02 17:22:49

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; }