#include #include #ifndef IO_HPP #define IO_HPP #include #include #include #include #include #include #include #include #include using namespace std; templateistream &operator>>(istream&,pair&); templateistream &operator>>(istream&,tuple&a); templateistream &operator>>(istream&is,vector&a); templateistream &operator>>(istream&is,array&a); template istream &operator>>(istream&is,pair&a){ is>>a.first>>a.second; return is; } template void read_tuple(istream&is,tuple&a){ if constexpr(pos>::value){ is>>get(a); read_tuple(is,a); } } template istream &operator>>(istream&is,tuple&a){ read_tuple<0>(is,a); return is; } template istream &operator>>(istream&is,vector&a){ for(T&x:a)is>>x; return is; } template istream &operator>>(istream&is,array&a){ for(T&x:a)is>>x; return is; } templateostream &operator<<(ostream&os,const pair&); templateostream &operator<<(ostream&os,const tuple&); templateostream &operator<<(ostream&os,const vector&); templateostream &operator<<(ostream&os,priority_queue); templateostream &operator<<(ostream&os,queue); templateostream &operator<<(ostream&os,deque); templateostream &operator<<(ostream&os,stack); templateostream &operator<<(ostream&os,const array&); templateostream &operator<<(ostream&os,const map&); templateostream &operator<<(ostream&os,const unordered_map&); templateostream &operator<<(ostream&os,const set&); templateostream &operator<<(ostream&os,const multiset&); templateostream &operator<<(ostream&os,const unordered_set&); template ostream &operator<<(ostream&os,const pair&a){ os< void write_tuple(ostream&os,const tuple&a){ if constexpr(pos>::value){ if constexpr(pos>0)os<<' '; os<(a); write_tuple(os,a); } } template ostream &operator<<(ostream&os,const tuple&a){ write_tuple<0>(os,a); return os; } template ostream &operator<<(ostream&os,const vector&a){ os<<'{'; for(int i=0;i<(int)a.size();i++){ os< ostream &operator<<(ostream&os,priority_queuea){ os<<'{'; if(!a.empty()){ os< ostream &operator<<(ostream&os,queuea){ os<<'{'; if(!a.empty()){ os< ostream &operator<<(ostream&os,dequea){ os<<'{'; if(!a.empty()){ os< ostream &operator<<(ostream&os,stacka){ os<<'{'; if(!a.empty()){ os< ostream &operator<<(ostream&os,const array&a){ os<<'{'; for(int i=0;i<(int)a.size();i++){ os< ostream &operator<<(ostream&os,const map&a){ if(a.empty()){ os<<"{}"; return os; } auto itr=a.begin(); os<<"{["<first<<","<second<<']'; while(++itr!=a.end())os<<",["<first<<','<second<<']'; os<<'}'; return os; } template ostream &operator<<(ostream&os,const unordered_map&a){ if(a.empty()){ os<<"{}"; return os; } auto itr=a.begin(); os<<"{["<first<<","<second<<']'; while(++itr!=a.end())os<<",["<first<<','<second<<']'; os<<'}'; return os; } template ostream &operator<<(ostream&os,const set&a){ if(a.empty()){ os<<"{}"; return os; } auto itr=a.begin(); os<<'{'<<*itr; while(++itr!=a.end())os<<','<<*itr; os<<'}'; return os; } template ostream &operator<<(ostream&os,const multiset&a){ if(a.empty()){ os<<"{}"; return os; } auto itr=a.begin(); os<<'{'<<*itr; while(++itr!=a.end())os<<','<<*itr; os<<'}'; return os; } template ostream &operator<<(ostream&os,const unordered_set&a){ if(a.empty()){ os<<"{}"; return os; } auto itr=a.begin(); os<<'{'<<*itr; while(++itr!=a.end())os<<','<<*itr; os<<'}'; return os; } #endif using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} templatevoid operator++(pair&a,int){a.first++,a.second++;} templatevoid operator--(pair&a,int){a.first--,a.second--;} templatevoid operator++(vector&a,int){for(auto &i:a)i++;} templatevoid operator--(vector&a,int){for(auto &i:a)i--;} using vref=typename vector::reference; vref operator|=(vref a,bool b){a=a|b;return a;} vref operator&=(vref a,bool b){a=a&b;return a;} vref operator^=(vref a,bool b){a=a^b;return a;} #define overload3(_1,_2,_3,name,...) name #define rep1(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define rep(...) overload3(__VA_ARGS__,rep2,rep1)(__VA_ARGS__) #define reps(i,l,r) rep2(i,l,r) #define all(x) x.begin(),x.end() #define pcnt(x) __builtin_popcountll(x) #define fin(x) return cout<<(x)<<'\n',static_cast(0) #define yn(x) cout<<((x)?"Yes\n":"No\n") #define uniq(x) sort(all(x)),x.erase(unique(all(x)),x.end()) template inline int fkey(vector&z,T key){return lower_bound(z.begin(),z.end(),key)-z.begin();} ll myceil(ll a,ll b){return (a+b-1)/b;} template auto vec(const int (&d)[n],const T &init=T()){ if constexpr (id(d,init)); else return init; } #ifdef LOCAL #include #define SWITCH(a,b) (a) #else #define debug(...) static_cast(0) #define debugg(...) static_cast(0) #define SWITCH(a,b) (b) #endif struct Timer{ clock_t start; Timer(){ start=clock(); ios::sync_with_stdio(false); cin.tie(nullptr); cout<>testcase; for(int i=0;i #include #include template constexpr std::enable_if_t::digits<=32,int>msb(T n){return n==0?-1:31-__builtin_clz(n);} template constexpr std::enable_if_t<(std::numeric_limits::digits>32),int>msb(T n){return n==0?-1:63-__builtin_clzll(n);} template constexpr std::enable_if_t::digits<=32,int>lsb(T n){return n==0?-1:__builtin_ctz(n);} template constexpr std::enable_if_t<(std::numeric_limits::digits>32),int>lsb(T n){return n==0?-1:__builtin_ctzll(n);} template constexpr std::enable_if_t,T>floor_pow2(T n){return n==0?0:T(1)< constexpr std::enable_if_t,T>ceil_pow2(T n){return n<=1?1:T(1)<<(msb(n-1)+1);} template constexpr T safe_div(T a,T b){return a/b-(a%b&&(a^b)<0);} template constexpr T safe_ceil(T a,T b){return a/b+(a%b&&(a^b)>0);} namespace kth_bit_impl{ struct Pre{ std::int8_t table[1<<16][16]; Pre(){ for(int i=0;i<(1<<16);i++){ for(int j=0,x=i;x&&j<16;j++){ int l=lsb(x); table[i][j]=l; x^=1< int kth_bit(unsigned long long x,int k){ if constexpr(check_over){ if(std::popcount(x)<=k)return -1; } int c=std::popcount(x&-1u); if(k>16][k-d]+16; } else{ k-=c; unsigned int y=x>>32; int d=std::popcount(y&mask1); if(k>16][k-d]+48; } } } using kth_bit_impl::kth_bit; struct BinaryIndexedTree01{ int n,n64,z64; std::vectordat; std::vectora; explicit BinaryIndexedTree01(int n_):n(n_),n64((n_+63)>>6),z64(ceil_pow2(n64)){ dat.resize(n64,0); a.resize(n64,uint64_t(0)); } explicit BinaryIndexedTree01(const std::vector&init):n(init.size()),n64((n+63)>>6),z64(ceil_pow2(n64)){ dat.resize(n64); a.resize(n64); for(int i=0;i>6]|=uint64_t(1)<<(i&63); dat[i>>6]++; } for(int i=1;i<=n64;i++){ int j=i+(i&-i); if(j<=n64)dat[j-1]+=dat[i-1]; } } void set(int k,int x){ if((a[k>>6]>>(k&63)&1)==x)return; a[k>>6]^=uint64_t(1)<<(k&63); if(!x)x=-1; k>>=6; k++; while(k<=n64){ dat[k-1]+=x; k+=k&-k; } } int sum(int l,int r)const{ int ret=__builtin_popcountll(a[r>>6]&((uint64_t(1)<<(r&63))-1))-__builtin_popcountll(a[l>>6]&((uint64_t(1)<<(l&63))-1)); l>>=6,r>>=6; while(l=1;i>>=1){ if(res+i<=std::ssize(dat)&&dat[res+i-1](a[res],k-1); } }; constexpr int nmax=SWITCH(100,1000000); void SOLVE(){ int q; cin>>q; vectora(nmax+1); BinaryIndexedTree01 bit(nmax+1); while(q--){ int n,l,r; cin>>n>>l>>r; int s=sqrt(n); rep(i,1,s+1){ a[i]^=1; bit.set(i,a[i]); } rep(i,1,s){ a[n/i]^=1; bit.set(n/i,a[n/i]); } if(s!=n/s){ a[n/s]^=1; bit.set(n/s,a[n/s]); } cout<