当前位置:网站首页>Hangdian oj2092 integer solution

Hangdian oj2092 integer solution

2022-07-07 14:14:00 sinat_ thirty-six million seven hundred and eighty-nine thousan

  Write it down first , I don't know why I can't pass

 #include<iostream>
 #include<math.h>
 using namespace std;
 int main(){
 	int a,b;
 	bool cc;
	while(cin>>a>>b){
		cc=true;
		if(b==0&&a==0){
			exit(0);
		}
		if(b>0){
			for(int i=1;i<=pow(b,0.5);i++){
				if(b%i==0){
					if(i+b/i==a){
						cout<<"Yes"<<endl;
						cc=false;
						break;
					}
				}
			}
			if(cc){
				cout<<"No"<<endl;
			}
		}else if(b==0){
			cout<<"Yes"<<endl;
		}else{
			b=-1*b;
			for(int i=1;i<=pow(b,0.5);i++){
				if(b%i==0){
					if(-1*i+b/i==a||-1*b/i+i==a){
						cout<<"Yes"<<endl;
						cc=false;
						break;
					}
				}
			}
			if(cc){
				cout<<"No"<<endl;
			}
		}
	}
 }

 

原网站

版权声明
本文为[sinat_ thirty-six million seven hundred and eighty-nine thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071212223469.html