#include<bits/stdc++.h>using i64 =longlong;int n;voidsolve(){int ans =0;
std::vector<int>a(n);for(int i =0; i < n; i ++){
std::cin >> a[i];
ans ^= a[i];}if(!ans){
std::cout <<"0\n";return;}int res =0;for(int i =0; i < n; i ++){int k = ans ^ a[i];
res +=(a[i]> k);}
std::cout << res <<"\n";}intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);while(std::cin >> n and n){solve();}return0;}
#include<iostream>#include<algorithm>#include<cstring>using i64 =longlong;constint N =1100;int f[N][N];int n,m;
std::string a,b;voidsolve(){memset(f,0,sizeof f);
a =" "+ a,b =" "+ b;for(int i =0; i <= m; i ++) f[0][i]= i;for(int i =0; i <= n; i ++) f[i][0]= i;for(int i =1; i <= n; i ++)for(int j =1; j <= m; j ++){
f[i][j]= std::min(f[i -1][j],f[i][j -1])+1;
f[i][j]= std::min(f[i][j],a[i]== b[j]? f[i -1][j -1]: f[i -1][j -1]+1);}
std::cout << f[n][m]<<"\n";}intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);while(std::cin >> n >> a >> m >> b){solve();}return0;}
#include<bits/stdc++.h>using i64 =longlong;intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);int n,m;while(std::cin >> n >> m and(n or m)){if(n > m) std::swap(n,m);int k = m - n;int t =(1+ std::sqrt(5.0))/2* k;if(t == n) std::cout <<"0\n";else{
std::cout <<"1\n"<< t <<" "<< m - n + t <<"\n";int s =(std::sqrt(5.0)-1)/2* n;
std::cout << s <<" "<< n <<"\n";}}return0;}
#include<bits/stdc++.h>using i64 =longlong;const i64 mod =9973;//a^b%ptemplate<classT>
T qmi(T a, i64 b,T p){int res =1% p;while(b){if(b &1) res =(i64)res * a % p;
a = a *(i64)a % p;
b >>=1;}return res;}voidsolve(){
i64 a,b;
std::cin >> a >> b;
i64 t =qmi(b,mod -2,mod);
std::cout << a * t % mod <<"\n";}intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);int T;
std::cin >> T;while(T --){solve();}return0;}
扩展欧几里得求逆元
#include<bits/stdc++.h>using i64 =longlong;const i64 mod =9973;intexgcd(int a,int b,int&x,int&y){if(b==0){
x=1,y=0;return a;}int d=exgcd(b,a%b,y,x);
y -=(a/b)*x;return d;}intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);int t;
std::cin >> t;while(t--){int n,b,x,y;
std::cin >> n >> b;int d =exgcd(b,mod,x,y);
x =((x % mod)+mod)% mod;
std::cout <<((x * n)% mod )% mod <<"\n";}return0;}
#include<iostream>#include<cstring>#include<algorithm>constint N =32010;int n;int res[N];区间修改,单点查询int c[N];//c[x]表示a[x - lowbit(x) + 1,x] 之间所有数的和structBT{intlowbit(int x){return x&(-x);}voidadd(int x,int v){for(int i = x; i <= N; i +=lowbit(i))
c[i]+= v;}intquery(int x){int ans =0;for(int i = x; i; i -=lowbit(i)) ans += c[i];return ans;}}BTree;intmain(){
std::cin >> n;for(int i =1; i <= n; i ++){int x,y;
std::cin >> x >> y;
x ++;
res[BTree.query(x)]++;
BTree.add(x,1);}for(int i =0; i < n; i ++)
std::cout << res[i]<<"\n";return0;}
#include<bits/stdc++.h>using i64 =longlong;constint N =110;int g[N][N];int n;intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);int a,b,k =1;while(std::cin >> a >> b,(a or b)){memset(g,0x3f,sizeof g);
g[a][b]=1;int n =0;while(1){
std::cin >> a >> b;
n = std::max(n,std::max(a,b));
g[a][b]=1;if(a ==0and b ==0)break;}for(int i =0; i <= n; i ++) g[i][i]=0;auto floyd =[&](){for(int k =1; k <= n; k ++)for(int i =1; i <= n; i ++)for(int j =1; j <= n; j ++)
g[i][j]= std::min(g[i][j],g[i][k]+ g[k][j]);};floyd();int sum =0;int cnt =0;for(int i =1; i <= n; i ++)for(int j =1; j <= n; j ++)if(g[i][j]!=0x3f3f3f3fand g[i][j]>0){
sum += g[i][j];
cnt ++;}
std::cout <<"Case "<< k <<": average length between pages = "<< std::fixed << std::setprecision(3)<<(double)sum / cnt <<" clicks\n";
k ++;}return0;}
#include<bits/stdc++.h>using i64 =longlong;//通解:x = x0 + k*(b/d) y = y0 + k*(a/d)intexgcd(int a,int b,int&x,int&y){if(!b){
x =1,y =0;return a;}int d =exgcd(b,a%b,y,x);
y -= a / b * x;return d;}intmain(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);int a,b;
std::cin >> a >> b;int x,y;exgcd(a,b,x,y);
std::cout <<(x % b + b)% b <<"\n";return0;}