1 #include<bits/stdc++.h> 2 using namespace std; 3 #define rep(i,a,b) for(int i=a;i<=b;++i) 4 #define ms(arr,a) memset(arr,a,sizeof arr) 5 #define debug(x) cout<<"< "#x" = "<<x<<" >"<<endl 6 7 int main() 8 { 9 //freopen("Input.txt","r",stdin); 10 //freopen("Output.txt","w",stdout); 11 int T;scanf("%d",&T); 12 while(T--) 13 { 14 int a,b,c,n; 15 scanf("%d%d",&n,&a); 16 if(n>2||n==0){printf("-1 -1\n");continue;} 17 if(n==1){printf("%d %d\n",1,a+1);continue;} 18 int fac; 19 bool flag=false; 20 for(fac=1;fac<=int(sqrt(a));fac++) 21 { 22 int x=a/fac*a%2; 23 if(a%fac==0) 24 if(fac%2==x) 25 { 26 flag=true; 27 break; 28 } 29 } 30 if(flag==false)printf("-1 -1\n"); 31 else printf("%d %d\n",(a/fac*a-fac)/2,(fac+a/fac*a)/2); 32 } 33 //freopen("CON","w",stdout); 34 //system("start Output.txt"); 35 }
原文地址:https://www.cnblogs.com/maoruimas/p/9534876.html
时间: 2024-11-05 23:05:22