思路
对于每一道题,有两种选择:勾选与取消勾选。
拓展到 道题上,最坏的操作次数就是 次。
而每道选择题不能都不选,因此需要减去一个操作次数。
AC Code
第一种:
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int E=1e6+5;
ll n;
int main(){
IO;
cin >>n;
cout <<(1<<n)-1;
return 0;
}第二种:
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int E=1e6+5;
ll n;
int main(){
IO;
cin >>n;
ll ans=pow(2,n);
cout <<ans-1;
return 0;
}