View Code of Problem 60

#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;
        if(s == 1){
            cout << "Scenario #" << i << ":" << endl << "2" << endl;
            continue;
        }
        total = pow(2, s);
        sum = total / 4 * 3;
        for(int j = 0; j < total / 4 * 3; 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.


Back to problem 60