目录
1,题目描述
Sample Input:
3
167334
2333
12345678
Sample Output:
Yes
No
No
2,思路
注意除0的情况。
SHOW CODE.
3,AC代码
#include<bits/stdc++.h>
using namespace std;
bool judge(string x){
int a, b, num = stoi(x);
int div = pow(10, x.size()/2);
a = num / div;
b = num % div;
if(a == 0 || b == 0)
return false;
if(num % (a*b) == 0)
return true;
else
return false;
}
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
int N;
string s;
cin>>N;
for(int i = 0; i < N; i++){
cin>>s;
printf("%s\n", judge(s) ? "Yes" : "No");
}
return 0;
}
4,解题过程
第一搏
看上去是道水题。。。
#include<bits/stdc++.h>
using namespace std;
bool judge(string x){
int a, b, num = stoi(x);
int div = pow(10, x.size()/2);
a = num / div;
b = num % div;
if(num % (a*b) == 0)
return true;
else
return false;
}
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
int N;
string s;
cin>>N;
for(int i = 0; i < N; i++){
cin>>s;
printf("%s\n", judge(s) ? "Yes" : "No");
}
return 0;
}
第二搏
恍然大悟,于是: