Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
55011 | zhangweiran | 计算2的N次方 | C++ | Accepted | 0 MS | 244 KB | 381 | 2024-11-02 08:15:47 |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[100]; memset(a,0,sizeof(a)); a[0] = 1; int m = 1; for(int j = 1; j <= n; j++) { int t = 0; for(int j = 0; j < m; j++) { t += a[j] * 2; a[j] = t % 10; t /= 10; } if(t > 0) a[m++] = 1; } for(int i = m-1; i >= 0; i--) { cout << a[i]; } return 0; }