#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("trapv")
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define pp(x) pop_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)
using namespace std;
///~~~~~~~~~~~~~~~~~~~~~~~~~~
template <typename H, typename T>
ostream& operator<<(ostream& os, pair<H, T> m){
return os <<"("<< m.st<<", "<<m.nd<<")";
}
template <typename H>
ostream& operator<<(ostream& os, vector<H> V){
os<<"{";
for(int i=0; i<V.size(); i++){
if(i)os<<" ";
os<<V[i];
}
os<<"}";
return os;
}
void debug(){cerr<<"\n";}
template <typename H, typename... T>
void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);}
#define deb(x...) cerr<<#x<<" = ";debug(x);
///~~~~~~~~~~~~~~~~~~~~~~~~~
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=1e6+5, INF=1e9+5, mod2=1e9+7, mod=998244353;
struct modint{
int n=0;
modint(){}
modint(ll x){
n=x%mod;
if(n<0)n+=mod;
}
operator int(){
return n;
}
modint operator+(modint a){a.n = n+a.n; if(a.n>=mod)a.n-=mod;return a;}
modint operator+=(modint a){return (*this)=(*this)+a;}
modint operator-(modint a){a.n = n-a.n; if(a.n<0)a.n+=mod;return a;}
modint operator-=(modint a){return (*this)=(*this)-a;}
modint operator*(modint a){a.n = (n*1ll*a.n)%mod; return a;}
modint operator*=(modint a){return (*this)=(*this)*a;}
modint pot(const ll &m)const{
modint a(1);
if(m==0)return a;
if(m==1)return (*this);
a=(*this).pot(m/2);
a*=a;
return a*((*this).pot(m&1));
}
modint odw(){
return (*this).pot(mod-2);
}
modint operator/(modint a){return (*this)*a.odw();}
modint operator/=(modint a){return (*this)=(*this)/a;}
bool operator==(modint a){return a.n==n;}
friend ostream& operator<<(ostream& os, modint m) {
return os << m.n;
}
};
modint fact[N], fact2[N];
typedef vector<modint> vm;
void factinit(){
fact[0]=1;
for(int i=1; i<N; i++){
fact[i]=(fact[i-1]*modint(i))%mod;
}
fact2[N-1]=fact[N-1].odw();
for(int i=N-2; i>=0; i--){
fact2[i]=(fact2[i+1]*modint(i+1))%mod;
}
}
modint npok(int _n, int _k){
return fact[_n]*fact2[_k]*fact2[_n-_k];
}
bool czy(int a, int b){
if(a==-1 )return (b==-1);
return (a|b)==b;
}
int ile[60];
ll tab[60];
int main(){
//factinit();
//BOOST;
ll n, x,y ;
cin>>n>>x>>y;
ll ans=0;
for(int yy=y; yy<=y; yy++){
if(czy(yy, y)){
for(int i=0; i<60; i++)tab[i]=0, ile[i]=0;
for(int i=0; i<20; i++){
for(int j=0; j<40; j++){
if((1ll<<i)&yy && (1ll<<j)&n){
tab[i+j]+=(1ll<<j);
ile[i+j]++;
}
}
}
vector<pair<ll, ll> > V;
V.eb(0, 0);
for(int i=0; i<3; i++){
vector<pair<ll, ll> > V2;
deb(ile[i], tab[i]);
for(int k=0; k<=ile[i]; k++){
if(1){
deb(k);
for(auto j:V){
deb("b", j.st+(ll(k)<<i), x, (1ll<<(i+1))-1);
if(((x^(j.st+(ll(k)<<i)))&((1ll<<(i+1))-1))==0){
deb("q", czy(k-1, ile[i]-1));
if(czy(k-1, ile[i]-1))V2.eb(j.st+(ll(k)<<i), j.nd^tab[i]);
else V2.eb(j.st+(ll(k)<<i), j.nd);
}
}
}
}
deb(i, V, V2);
V.clear();
if(!V2.size())break;
sor(V2);
for(int j=0; j<=V2.size(); j++){
if(j>0 && (j==V2.size() || V2[j].st!=V2[j-1].st)){
V.pb(V2[j-1]);
}
if(j==V2.size())break;
if(j)V2[j].nd^=V2[j-1].nd;
}
deb(V);
}
if(V.size()){
ans^=V[0].nd;
deb(yy, V[0].nd);
}
deb(yy);
deb(yy);
deb(yy);
}
}
cout<<ans;
}
Compilation message
bodyguard.cpp: In function 'int main()':
bodyguard.cpp:154:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
154 | for(int j=0; j<=V2.size(); j++){
| ~^~~~~~~~~~~
bodyguard.cpp:155:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
155 | if(j>0 && (j==V2.size() || V2[j].st!=V2[j-1].st)){
| ~^~~~~~~~~~~
bodyguard.cpp:158:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
158 | if(j==V2.size())break;
| ~^~~~~~~~~~~
bodyguard.cpp: In instantiation of 'std::ostream& operator<<(std::ostream&, std::vector<_Tp>) [with H = std::pair<long long int, long long int>; std::ostream = std::basic_ostream<char>]':
bodyguard.cpp:39:30: required from 'void debug(H, T ...) [with H = std::vector<std::pair<long long int, long long int> >; T = {}]'
bodyguard.cpp:161:3: required from here
bodyguard.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i=0; i<V.size(); i++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
8148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |