题目难度:两颗星
题目大意:把一个数分成前后两个相等的两份,然后看分成的两个数的乘积能否整除这个数。
题目坑点:第一遍提交的时候搞出了一个没遇到的浮点错误。。。然后点进去一看,原来是不小心除以零了。。。因为分割的时候,后一部分可能都是零,因此乘积也就是零。。。一定要考虑周全
代码如下:
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
int string2int(string s){
int res=0;
for(int i=0;i<s.length();i++){
res=res*10+s[i]-'0';
}
return res;
}
int main(){
int N,b,a,t;
string temp,bef,aft;
cin>>N;
for(int i=0;i<N;i++){
cin>>temp;
bef=temp.substr(0,temp.length()/2);
aft=temp.substr(temp.length()/2,temp.length());
b=string2int(bef);
a=string2int(aft);
t=string2int(temp);
int pro=b*a;
if(pro<=0||pro>t||t%pro!=0)
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
}