#include<bits/stdc++.h>
using namespace std;
const int V=5e4;
typedef bitset<V+1> B;
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n,m,q; cin>>n>>m>>q;
vector<B> a(n+m+1);
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j+=i)
a[i].set(j);
for(int i=n+1;i<=n+m;i++){
int op,x,y; cin>>op>>x;
switch(op){
case 1:cin>>y,a[i]=a[x]|a[y]; break;
case 2:cin>>y,a[i]=a[x]&a[y]; break;
case 3:a[i]=a[1]^a[x]; break;
}
}
while(q--){
int x,y; cin>>x>>y;
cout<<(a[x][y]?"TAK\n":"NIE\n");
}
return 0;
}
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 | #include<bits/stdc++.h> using namespace std; const int V=5e4; typedef bitset<V+1> B; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,m,q; cin>>n>>m>>q; vector<B> a(n+m+1); for(int i=1;i<=n;i++) for(int j=i;j<=n;j+=i) a[i].set(j); for(int i=n+1;i<=n+m;i++){ int op,x,y; cin>>op>>x; switch(op){ case 1:cin>>y,a[i]=a[x]|a[y]; break; case 2:cin>>y,a[i]=a[x]&a[y]; break; case 3:a[i]=a[1]^a[x]; break; } } while(q--){ int x,y; cin>>x>>y; cout<<(a[x][y]?"TAK\n":"NIE\n"); } return 0; } |
English