PAT甲级——A1132 Cut Integer

时间:2019-09-08
本文章向大家介绍PAT甲级——A1132 Cut Integer,主要包括PAT甲级——A1132 Cut Integer使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

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 × 334) = 3. Given an integer Z, you are supposed to test if it is such an integer.

Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N (≤ 20). Then N lines follow, each gives an integer Z (10 ≤ Z <). It is guaranteed that the number of digits of Z is an even number.

Output Specification:

For each case, print a single line Yes if it is such a number, or No if not.

Sample Input:

3
167334
2333
12345678

Sample Output:

Yes
No
No

 1 #include <iostream>
 2 #include <string>
 3 using namespace std;
 4 int main()
 5 {
 6     int n, num, a, b;
 7     cin >> n;
 8     while (n--)
 9     {
10         string str, str1, str2;
11         cin >> str;
12         str1.assign(str.begin(), str.begin() + str.length() / 2);
13         str2.assign(str.begin() + str.length() / 2, str.end());
14         num = atoi(str.c_str());
15         a = atoi(str1.c_str());
16         b = atoi(str2.c_str());
17         if ((a*b) > 0 && num % (a*b) == 0)
18             cout << "Yes" << endl;
19         else
20             cout << "No" << endl;
21     }
22     return 0;
23     
24 }


原文地址:https://www.cnblogs.com/zzw1024/p/11488215.html