#include <bits/stdc++.h> using namespace std; int main() { int n, s, sum, total, checkFlag, tmp; cin >> n; for(int i = 1; i <= n; i++){ cin >> s; total = pow(2, s); sum = total; for(int j = 0; j < total; j++){ tmp = j; checkFlag = 0; while(tmp){ if(!(tmp%2)) checkFlag = 0; else{ if((!checkFlag) && (tmp%2)) checkFlag = 1; else if((checkFlag) && (tmp%2)){ sum --; checkFlag = 0; break; } } tmp /= 2; } } cout << "Scenario #" << i << ":" << endl << sum << endl; } return 0; } |
Double click to view unformatted code.