Task: | Neliöt |
Sender: | ollpu |
Submission time: | 2020-11-06 18:08:11 +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.12 s | 2 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:18:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (j < sq.size() && sq[j] == x) f=1; ~~^~~~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; vector<int> sq; for (int i = 0; i*i <= int(1e9); ++i) sq.push_back(i*i); for (int Ti = 0; Ti < T; ++Ti) { int n; cin >> n; bool f=0; for (int a : sq) { if (a > n) break; int x = n-a; int j = lower_bound(sq.begin(), sq.end(), x)-sq.begin(); if (j < sq.size() && sq[j] == x) f=1; } if (f) 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 |