- Published on
Codeforces: Good Bye 2023
A. 2023
c1916A.cpp
//...
int n, k;
cin >> n >> k;
vector<int> b;
int product = 1;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
b.push_back(x);
product *= x;
}
int rem = 2023 / product;
double rem2 = 2023.0 / product;
if (rem2 != rem)
{
cout << "NO" << endl;
}
else
{
cout << "YES" << endl;
cout << rem << " ";
for (int i = 1; i < k; i++)
{
cout << 1 << " ";
}
cout << endl;
}
//...
B. Two Divisors
int smallestDivisor(int a)
{
for (int i = 2; i <= a; ++i)
{
if (a % i == 0)
{
return i;
}
}
return a;
}
c1916B.cpp
//...
long long a, b;
cin >> a >> b;
int ans = (a * b) / __gcd(a, b);
if (ans > max(a, b))
{
cout << ans << endl;
}
else
{
cout << max(a, b) * smallestDivisor(max(a, b)) << endl;
}
//...
C. Training Before the Olympiad
c1916C.cpp
//...
int n;
cin >> n;
int odds = 0, oddPairs = 0;
long long sum = 0;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
sum += x;
if (x % 2 == 1)
{
odds++;
}
oddPairs = odds / 2;
if (!oddPairs && odds && i != 0)
{
sum--;
}
while (oddPairs)
{
oddPairs--;
int tempOdd = odds - 2;
if (tempOdd)
{
sum--;
}
}
cout << sum << " ";
}
cout << endl;
//...
Published: Last edited: