cd106224 edited 4 年,9 月前
不清楚为什么与答案不相符
//状态:dp[i][j]表示打第i个响指,第j个开关的状态;
#include <iostream>
#include <string.h>
using namespace std;
int dp[102][12];
int n, k;
int main() {
int num;
cin >> num;
for(int l=1;l<=num;++l){
memset(dp, 0, sizeof(dp));
cin >> n >> k;
for (int i = 1; i <= k; ++i) {
if (i & 1) {
dp[i][1] = 1;
}
}
for (int j = 2; j <= 11; ++j) {
int ans = 0;
for (int i = j; i <= k; ++i) {
bool temp = true;
for (int p = 1; p < j; ++p) {
if (!dp[i - 1][p]) {
temp = false;
break;
}
}
if (temp) {
dp[i][j] = !dp[i - 1][j];
}
else {
dp[i][j] = dp[i - 1][j];
}
}
}
if (dp[k][n]) {
cout << "Case " << l << ": ON" << endl;
}
else {
cout << "Case " << l << ": OFF" << endl;
}
}
return 0;
}