Task: | Neliöt |
Sender: | Olli |
Submission time: | 2020-11-06 18:04:05 +0200 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 28 |
#2 | ACCEPTED | 72 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.02 s | 1, 2 | details |
#2 | ACCEPTED | 0.02 s | 1, 2 | details |
#3 | ACCEPTED | 0.02 s | 2 | details |
Code
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <queue> #include <stack> #include <set> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define F first #define S second #define X first #define Y second const int N = 1e5 + 5; const ll INF = 1e18; int gpd[N]; bool pr[N]; void sieve() { for(int i = 2; i < N; ++i) { pr[i] = true; } for(ll i = 2; i < N; ++i) { if(!pr[i]) continue; gpd[i] = i; for(ll j = 2*i; j < N; j+=i) { gpd[j] = i; pr[j] = false; } } } int main() { sieve(); int t; cin >> t; while(t > 0) { --t; ll n; cin >> n; bool ans = true; for(int j = 2; j <= 1e5; ++j) { if(!pr[j]) continue; if(n%j == 0) { if(j%4 == 3) { int e = 0; while(n%j == 0) { n/=j; ++e; } if(e%2 == 1) { ans = false; break; } } while(n%j == 0) { n/=j; } } } if(n != 1) { if(n%4 == 3) { ans = false; } } if(ans) { cout << "YES\n"; } else { cout << "NO\n"; } } }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 1 2 3 4 ... |
correct output |
---|
YES YES NO YES YES ... |
user output |
---|
YES YES NO YES YES ... Truncated |
Test 2
Group: 1, 2
Verdict: ACCEPTED
input |
---|
100 522 419 402 969 ... |
correct output |
---|
YES NO NO NO NO ... |
user output |
---|
YES NO NO NO NO ... Truncated |
Test 3
Group: 2
Verdict: ACCEPTED
input |
---|
100 575833539 744851460 436154655 655319365 ... |
correct output |
---|
NO NO NO NO NO ... |
user output |
---|
NO NO NO NO NO ... Truncated |