 # Help in wrong submission in problem chef vs Doof in coders legacy

The first solution that i submistted was finding LCM of all numbers and if LCM is even then answer is NO else YES . Can someone tell what is wrong in solution ? I don’t think overflow is problem since crossing LONG_LONG_MAX means automatically taking modulo 2^{64} and modulo by even number will not change the parity . submission . EDIT : i think it can cause divisibility problem .

Overflow is the issue.
LCM = Product of highest powers of each prime.
This means that if any number is even, the LCM is also even.
The problem reduces to check if there are even numbers.
Code:

``````#include <bits/stdc++.h>

using namespace std;

int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--)
{
int n, x;
cin >> n;
bool ok = 1;
for (int i = 0; i < n; ++i)
{
cin >> x;
if (x&1^1) ok = 0;
}
if (ok) cout << "YES\n";
else cout << "NO\n";
}
}
``````

I know that . I wanted to know what is wrong in LCM solution and i think it is probably causing divisibility problem after overflow since modulo might not divide .

If you try to print `(long long)1e19`, you get `9223372036854775807` which is totally wrong. You can easily see that the LCM will be greater than `1e18`.