1132. Cut Integer (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 思路
水题
1.首先如果输入的数Z的位数为奇数肯定不满足条件,输出No。
2.如果A乘B为0,肯定不满足条件,输出No
3.剩下情况检查Z % (A*B) 是否为0即可。
代码
#include<iostream>
#include<string>
using namespace std;
int main()
{
int N;
while(cin >> N)
{
while(N--)
{
string num;
cin >> num;
int len = num.size();
if(len % == )
{
cout << "No" << endl;
continue;
} string a = num.substr(,len/);
string b = num.substr(len/,len/);
int A = stoi(a),B = stoi(b),Z = stoi(num);
if(A * B != && Z % (A * B) == )
{
cout << "Yes" << endl;
}
else
cout << "No" << endl; }
}
}

PAT1132: Cut Integer的更多相关文章

  1. PAT-1132 Cut Integer (整数分割)

    Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long int ...

  2. PAT-1132(Cut Integer )数的拆分+简单题

    Cut Integer PAT-1132 #include<iostream> #include<cstring> #include<string> #includ ...

  3. PAT 1132 Cut Integer

    1132 Cut Integer (20 分)   Cutting an integer means to cut a K digits lone integer Z into two integer ...

  4. PAT 1132 Cut Integer[简单]

    1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...

  5. PAT_A1132#Cut Integer

    Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone in ...

  6. pat 1132 Cut Integer(20 分)

    1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...

  7. A1132. Cut Integer

    Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long int ...

  8. PAT A1132 Cut Integer (20 分)——数学题

    Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long int ...

  9. PAT 甲级 1132 Cut Integer

    https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...

随机推荐

  1. FFMPEG列出DirectShow支持的设备

    FFMPEG列出dshow支持的设备: ffmpeg -list_devices true -f dshow -idummy 举例: 采集摄像头和麦克风 ffmpeg -f dshow -i vide ...

  2. SpriteBuilder中频繁的切换场景层的解决办法

    注意,不像SettingsLayer,CCScrollView实例并没有从场景中删除和重新加载像代码所示的那样. 你只是简单的改变其可视(visible)状态on和off. 改变可视状态比加载CCB或 ...

  3. 不用局部变量实现C语言两数交换算法

    关于交换算法,我想非常简单,所以,这次不做分析,直接上代码: #include <stdio.h> #include <stdlib.h> //用异或方式实现 void swa ...

  4. 安卓笔记--- intent传递自定义类

    <span style="font-family: Arial, Helvetica, sans-serif;">eat.setOnClickListener(new ...

  5. shell脚本里面相互调用时路径不要用pwd获取

    shellA调用shellB,如果shellB 里面需要使用路径作为变量,去寻找其它文件.那么要注意,不用pwd,其返回的是系统中用户当前所在位置的路径,也就是shellA的路径,这样就错了.应该用d ...

  6. 关于NSKeyedArchiver的编码格式

    NSKeyedArchiver在linux的实现默认的格式是二进制: NSArray *ary = @[@"hello",@"world",@"!!! ...

  7. How tomcat works 读书笔记十四 服务器组件和服务组件

    之前的项目还是有些问题的,例如 1 只能有一个连接器,只能处理http请求,无法添加另外一个连接器用来处理https. 2 对容器的关闭只能是粗暴的关闭Bootstrap. 服务器组件 org.apa ...

  8. mahout系列----Dirichlet 分布

    Dirichlet分布可以看做是分布之上的分布.如何理解这句话,我们可以先举个例子:假设我们有一个骰子,其有六面,分别为{1,2,3,4,5,6}.现在我们做了10000次投掷的实验,得到的实验结果是 ...

  9. DB Query Analyzer 6.01 is released, SQL Execute Schedule function can be used

       DB Query Analyzer is presented by Master Gen feng, Ma from Chinese Mainland. It has English versi ...

  10. obj-c编程17:键值观察(KVO)

    说完了前面一篇KVC,不能不说说它的应用KVO(Key-Value Observing)喽.KVO类似于ruby里的hook功能,就是当一个对象属性发生变化时,观察者可以跟踪变化,进而观察或是修正这个 ...