Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Kanan Asgarli
- https://www.e-olymp.com/az/problems/2761
- */
- #include <iostream>
- #include <cmath>
- using namespace std;
- int n, res, y, x, d1, d2, tests;
- int main()
- {
- cin>>tests;
- while(tests--){
- cin>>n;
- res = 1000000001;
- for(int i = 1; i <= sqrt(n); i++)
- if( n % i == 0 ){
- d1 = i;
- d2 = n/i;
- if((d1 + d2)%2 == 0){
- y = (d1 + d2)/2;
- x = y - d1;
- if( x > 0 && res > x )
- res = x;
- }
- }
- if( res == 1000000001 )
- res = -1;
- cout<<res<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment