就是把两个数拆成两截,然后看能不能被两部分整除~
int 就足够了 没有溢出的情况
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
int n ;
string num;
int a,b,z;
bool str2num(string n){
int half = n.length()/2;
int i = 0;
a = 0 ,b= 0,z= 0;
for(i = 0 ;i < half ; i++){
a *= 10;
a += int(n[i] - '0');
z *= 10;
z += int(n[i] - '0');
}
for(;i<n.length();i++){
z *= 10;
z += int(n[i] - '0');
b *= 10;
b += int(n[i] - '0');
}
if(z == 0 || b == 0 || a == 0)
return false;
if(z % a == 0 && z /a % b == 0)
return true;
else
return false;
}
int main(){
cin >> n;
for(int i = 0 ;i < n ;i++){
cin >> num ;
if(str2num(num))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}