其他分享
首页 > 其他分享> > PAT(Advanced Level)A1132. Cut Integer

PAT(Advanced Level)A1132. Cut Integer

作者:互联网

题意

将一个长度为K的数字Z对半分,前半部分和后半部分各自构成了A和B两个数字,问A*B是否为Z的因子

思路

代码

#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N;
    cin >> N;
    string s;
    for(int i = 0; i < N; i++) {
        cin >> s;
        int A = stoi(s.substr(0, s.size() / 2));
        int B = stoi(s.substr(s.size() / 2));
        int Z = stoi(s);
        if(A != 0 && B != 0 && Z % (A * B) == 0)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}

标签:Cut,PAT,A1132,int,substr,stoi,&&,include,size
来源: https://www.cnblogs.com/MartinLwx/p/14526474.html