-
Notifications
You must be signed in to change notification settings - Fork 33
/
Pythagorean Pair.cpp
60 lines (56 loc) · 1.06 KB
/
Pythagorean Pair.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vi vector<long long int>
#define vll vector<long long>
#define vs vector<string>
#define pii pair<int,int>
#define gcd __gcd
#define PI 3.1415926535897932384626433832795
#define inf INT_MAX
#define minf INT_MIN
#define lmax LLONG_MAX
#define pb push_back
#define MP make_pair
#define lb lower_bound
#define ub upper_bound
#define w(t) long long int t; cin>>t; while(t--)
#define all(x) x.begin(),x.end()
#define Big_Bang ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
const int MOD = 1e9 + 7;
const int modd = 1e6 + 4;
void solve()
{
ll int n,ct=0; cin>>n;
ll int p=0,q=sqrt(n);
for(int i=0;i<=q;i++)
{
for(int j=0;j<=q;j++)
{
if((i*i)+(j*j)==n)
{
cout<<i<<" "<<j<<endl;
ct++;
break;
}
}
if(ct==1)
{
break;
}
}
if(ct<1)
{
cout<<-1<<endl;
}
}
int main()
{
ios::sync_with_stdio(false),cin.tie(nullptr);
w(t)
{
solve();
}
return 0;
}