Task: | Neliöt |
Sender: | Grez |
Submission time: | 2020-11-07 09:09:32 +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.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 1, 2 | details |
#3 | ACCEPTED | 0.09 s | 2 | details |
Code
#include <iostream> #include <unordered_set> using namespace std; int squares[31623]; unordered_set<int> sqSet; void test(int num) { for (int j = 0; j < 31623; j++) { int sq = squares[j]; if (num < sq) break; if (sqSet.count(num - sq) > 0) { cout << "YES" << endl; return; } } cout << "NO" << endl; } int main() { for (int i = 0; i < 31623; i++) { squares[i] = i * i; sqSet.insert(squares[i]); } int amo; cin >> amo; for (int i = 0; i < amo; i++) { int num; cin >> num; test(num); } }
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 |