Task: | Neliöt |
Sender: | AtskaFin |
Submission time: | 2020-11-06 18:54:23 +0200 |
Language: | C++ (C++17) |
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 <string> #include <map> typedef long long ll; using namespace std; ll arr[31622]; map<int, int> m; int main() { int t; cin>>t; for (int i = 1; (ll)i*i < 1e9; i++) { arr[i-1] = i*i; m[i*i] = 1; } for (int i = 0; i < t; i++) { int x; cin>>x; if (m[x]) { cout << "YES" << "\n"; continue; } int a = 0, b = 31621; while (true) { if (a > b) { cout << "NO" << "\n"; break; } else if (arr[a]+arr[b]==x) { cout << "YES" << "\n"; break; } if (arr[a]+arr[b] < x) { a++; } else { b--; } } } }
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 |