Zerojudge c461

Zerojudge c461

題敘

https://zerojudge.tw/ShowProblem?problemid=c461
給三個數值,問經過 AND OR XOR 之後的值是否與要求相同

想法

直接照著題目做下去即可

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
bool c;
int A,B;
int main(){
IOS
while(cin>>A>>B>>c){
bool a=(A>0) ? true : false;
bool b=(B>0) ? true : false;
bool out=false;
if((a && b) == c){
cout<<"AND\n";
out=true;
}
if((a || b) == c){
cout<<"OR\n";
out=true;
}
if((a ^ b) == c){
cout<<"XOR\n";
out=true;
}
if(!out)
cout<<"IMPOSSIBLE\n";
}
return 0;
}

複雜度

$O(1)$

tags: Zerojudge