A
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 5e4 + 10;
int T;
int n;
int a[N];
int main()
{
cin >> T;
while(T -- )
{
cin >> n;
memset(a, 0, sizeof a);
for(int i = 0; i < n; i ++ )
{
cin >> a[i];
}
long long nn = 1e9 + 10;
for(long long i = 0, j = 1; j < n; i ++, j ++ )
{
long long t = max(a[i], a[j]);
nn = min(nn, t);
}
cout << nn - 1 << endl;
}
return 0;
}
B
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int a, b;
cin >> a >> b;
for (int i = 0; i < 30; i++)
{
if ((a & (1 << i)) != (b & (1 << i)))
{
cout << (1ll << i) << "\n";
break;
}
}
}
}
C
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
const int N = 1e9 + 10;
int gcd(int a, int b)
{
while (b != 0)
{
int tmp = a % b;
a = b;
b = tmp;
}
return a;
}
int lcm(int a, int b)
{
return a * b / gcd(a, b);
}
int main()
{
int t;
cin >> t;
while(t -- )
{
int n;
vector <int> a(n);
cin >> n;
for(int i = 0; i < n; i ++ )
{
cin >> a[i];
}
int zz = 1;
for(int i = 0; i < n; i ++ )
{
zz = lcm(zz, a[i]);
}
int sum = 0;
for(int i = 0; i < n; i ++ )
{
sum += (zz / a[i]);
}
if (sum < zz)
{
for (int i = 0; i < n; i++)
{
cout << zz / a[i] << " ";
}
cout << endl;
}
else
{
cout << -1 << "\n";
}
}
return 0;
}