zoukankan      html  css  js  c++  java
  • 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 }


  • 相关阅读:
    Oracle 11g系列:函数与存储过程
    Oracle 11g系列:视图
    Oracle 11g系列:约束
    Oracle 11g系列:数据表对象
    Oracle 11g系列:数据库
    Oracle 11g系列:SQL Plus与PL/SQL
    Ext.util.TaskRunner定时执行任务
    MS SQL Server存储过程
    UML基础:用例图Use Case Diagram(1)
    UML基础系列:类图
  • 原文地址:https://www.cnblogs.com/zzw1024/p/11488215.html
Copyright © 2011-2022 走看看