1132 Cut Integer
Statement
Metadata
- 作者: CHEN, Yue
- 单位: 浙江大学
- 代码长度限制: 16 KB
- 时间限制: 400 ms
- 内存限制: 64 MB
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by the product of A and B, as 167334 / (167
Input Specification
Each input file contains one test case. For each case, the first line gives a positive integer N (
Output Specification
For each case, print a single line Yes
if it is such a number, or No
if not.
Sample Input
Sample Output
Solution
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll x;
string s;
int main() {
int _T;
cin >> _T;
while (_T--) {
cin >> s;
ll x = 0, A = 0, B = 0;
for (int i = 0, len = s.size(); i < len; ++i) {
int c = s[i] - '0';
x = x * 10 + c;
if (i < len / 2) {
A = A * 10 + c;
} else {
B = B * 10 + c;
}
}
if (A == 0 || B == 0)
puts("No");
else {
if (x % A == 0 && (x / A) % B == 0) {
puts("Yes");
} else {
puts("No");
}
}
}
return 0;
}
Last update: May 4, 2022