课评: 转出学生归档(王子墨/张立坤/黄俊博)+ 周四班级总结 + 新生章梓皓档案 + C++示例代码
This commit is contained in:
22
C++代码/CSP04/02-简单排序/未命名2.cpp
Normal file
22
C++代码/CSP04/02-简单排序/未命名2.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define endl '\n'
|
||||
using namespace std;
|
||||
|
||||
int n;
|
||||
|
||||
int main(){
|
||||
cin >> n;
|
||||
|
||||
int cnt = 0;
|
||||
int curr = 1;
|
||||
|
||||
for(int i = 2; i <= n; i++){
|
||||
// 第i格有多少米
|
||||
curr = curr * 2;
|
||||
cnt += curr;
|
||||
}
|
||||
|
||||
cout << cnt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user