Task: | Neliöt |
Sender: | ArktinenKarpalo |
Submission time: | 2020-11-06 18:08:19 +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 |
Code
#include <bits/stdc++.h> #define ll long long #define ld long double #define M 1000000007 using namespace std; bool ok(ll t) { if(!t) return true; ll ans = 0; for(ll i=30; i>=0; i--) { ll lk = ans | (1<<i); if(lk*lk < t) { ans = lk; } } ans++; return (ans*ans == t); } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(); int t; cin >> t; for(int g=0; g<t; g++) { ll n; cin >> n; bool o = false; for(ll i=0; i*i<=n; i++) { if(ok(n-i*i)) { cout <<"YES\n"; o = true; break; } } if(!o) 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 |