1132. Cut Integer (20) 除零

简介: Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B.

Cutting an integer means to cut a K digits long 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 x 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<=231). 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
#include <iostream>
#include <string>
using namespace std;

int main() {
    int n;
    cin >> n;
    
    for (int i = 0; i < n; ++i){
        string s, s0, s1;
        cin >> s;
        s0 = s.substr(0, s.length()/2);
        s1 = s.substr(s.length()/2, s.length());
        long long a = stoi(s), b = stoi(s0), c = stoi(s1);
        if (b != 0 && c != 0) {
            if (a % (b * c) == 0){
                cout << "Yes" << endl;
                continue;
            }
        }
        cout << "No" << endl;
    }
    
    return 0;
}

目录
相关文章
|
3月前
|
Java API
将`List<String>`转换为`List<Long>`
将`List<String>`转换为`List<Long>`
|
4月前
|
Java
Integer类超详解-2
Integer类超详解
29 0
|
4月前
|
Java 编译器
Integer类超详解-1
Integer类超详解
35 0
|
4月前
|
网络协议 算法 Java
记录一道算法题-split和Integer.parseInt()
记录一道算法题-split和Integer.parseInt()
44 0
|
12月前
|
机器学习/深度学习
CF71A Way Too Long Words(string简单模拟)
CF71A Way Too Long Words(string简单模拟)
56 0
|
安全
Synchroinzed对Integer的问题
Synchroinzed对Integer的问题
109 0
Synchroinzed对Integer的问题
Zp
|
缓存 Java
Integer的比较和注意点
Integer的比较和注意点
Zp
85 0
Integer的比较和注意点
|
存储
7. Reverse Integer
7. Reverse Integer
80 0
|
存储 缓存 Java
聊聊 Integer 吧
当我们开发的越久,越能体会到基础知识的重要性。抽空捋一下 JDK 源码,权当查漏补缺。读完之后,你会发现 JDK 源码真的会给你很多惊喜
【1132】Cut Integer (20 分)
【1132】Cut Integer (20 分) 【1132】Cut Integer (20 分)
109 0