Find chopsticks
There is nothing to say, just the application of the basic XOR operation
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
int res=0;
while(n--)
{
int x;
scanf("%d",&x);
res=res^x;
}
printf("%d\n",res);
return 0;
}
serial number
This is the principle of multiplication. After
sorting the order, the multiplication is done.
#include <bits/stdc++.h>
using namespace std;
const int N = 60, MOD = 1000000007;
int x[N];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> x[i];
sort(x, x + n);
long long res = 1;
for (int i = 0; i < n; i++)
{
//cout<<"****"<<x[i]-i-1<<endl;
if(!i) res=res*x[i];
else
res = res * (x[i] - i) % MOD;
}
if (res < 0)
cout << "0" << endl;
else
cout << res << endl;
return 0;
}