3227. 声控开关 (Hard)

LUSTRE

include

using namespace std;
int main()
{
int T,Ti;
cin>>T;
for(Ti=0;Ti>N>>K;
if(!((K+1)%(1<<N)))
cout<<”Case “<<Ti+1<<”: ON”<<endl;
else
cout<<”Case “<<Ti+1<<”: OFF”<<endl;
}
return 0;
}

友利奈绪

//如果没特殊的样例就可以上升为easy了

include

include

using namespace std;

int main()
{
int t, n, k;
cin>>t;
for(int i = 1; i <= t; i++)
{
cin>>n>>k;
cout<<”Case “<<i<<’:’<<’ ‘;

    int judge = pow(2, n);
    if(judge - 1 != k % judge) cout<<"OFF"<<endl;
    else cout<<"ON"<<endl;
}

}

cd106224
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int num;
    cin >> num;
    for (int l = 1; l <= num; ++l) {
        int n, k;
        cin >> n >> k;
        int temp = 1;
        for (int i = 1; i <= n; ++i) {
            if ((k & (int)(pow(2, i) - 1)) != (int)(pow(2, i) - 1)) {
                temp = 0;
                break;
            }
        }

        if (temp) {
            cout << "Case " << l << ": ON" << endl;
        }
        else {
            cout << "Case " << l << ": OFF" << endl;
        }
    }
    return 0;
}
xcc120

为什么这个是HARD?直接把Easy的代码复制粘贴就行了。。。

你当前正在回复 博客/题目
存在问题!