原文鏈接:我的個人博客
原題鏈接
考點
字符串處理,字符串數字轉換
思路
將一個整數Z,切分成長度爲len/2的兩個部分A和B。再判斷Z是否能整除A*B
。
代碼
#include <bits/stdc++.h>
using namespace std;
int sti(string s){
int ans;
stringstream ss;
ss<<s;
ss>>ans;
return ans;
}
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
string s;
cin>>s;
int len = s.length();
string a = s.substr(0,len/2);
string b = s.substr(len/2);
int Z = sti(s);
int A = sti(a);
int B = sti(b);
if(A*B==0){
cout<<"No"<<endl;
}else{
if(Z%(A*B)==0){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
}
}