CSES - Putka Open 2020 – 4/5 - Results
Submission details
Task:Neliöt
Sender:Laakeri
Submission time:2020-11-06 22:39:39 +0200
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED28
#2ACCEPTED72
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s1, 2details
#3ACCEPTED0.03 s2details

Code

#include <bits/stdc++.h>
using namespace std;

bool isq(int x) {
	if (x < 0) return false;
	if (x <= 1) return true;
	double y=sqrt(x);
	int a=y;
	int b=y-1;
	int c=y+1;
	return a*a==x||b*b==x||c*c==x;
}

int main() {
	int tcs;
	cin>>tcs;
	for (int i=0;i<tcs;i++){
		int x;
		cin>>x;
		int f=0;
		for (int y=0;y*y<=x;y++){
			if (isq(x-y*y)) {
				f=1;
			}
		}
		if (f){
			cout<<"YES"<<endl;
		}else {
			cout<<"NO"<<endl;
		}
	}
}

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
...

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
...

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
...