Task: | Neliöt |
Sender: | tsiki2 |
Submission time: | 2020-11-07 20:41:54 +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.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 1, 2 | details |
#3 | ACCEPTED | 0.02 s | 2 | details |
Code
#include <stdio.h> // include before iostream for faster scanf #include <iostream> #include <vector> #include <string> #include <map> #include <unordered_map> #include <algorithm> #include <utility> #include <set> #include <unordered_set> #include <cmath> #include <math.h> #include <queue> #include <stdlib.h> #include <string.h> #include <sstream> #include <tuple> #include <utility> #include <iomanip> #include <iterator> using namespace std; typedef long long LL; #define printv(printVec) for (auto printVecIter : (printVec)) cout << printVecIter << " "; cout << endl; // g++ -Wall -Wshadow -std=c++11 a.cpp && ./a.out bool perf(int n) { double sq = sqrt(n); int a = (int) sq; int b = a + 1; return a*a == n || b*b == n; } bool test(int n) { for (int i = 1; i*i <= n; i++) { if (perf(n - i*i)) { return true; } } return false; } int main() { std::ios::sync_with_stdio(false);cin.tie(0); int t; cin>>t; while (t--) { int n; cin>>n; if (test(n)) { 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 |