目錄
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;
}
第二搏
恍然大悟,於是: