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 <2^31). 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<cstdio>
using namespace std;
long long Z;
int num2Cut(long long Z){
long long temp[], bit, Z2 = Z;
int pt = ;
do{
bit = Z % ;
Z = Z / ;
temp[pt++] = bit;
}while(Z != );
long long a = , b = ;
for(int i = pt - ; i >= pt / ; i--){
a = a * + temp[i];
}
for(int i = pt / - ; i >= ; i--){
b = b * + temp[i];
}
if(a*b == )
return ;
if(Z2 % (a*b) == )
return ;
else return ;
}
int main(){
int N;
scanf("%d", &N);
for(int i = ; i < N; i++){
scanf("%lld", &Z);
int tag = num2Cut(Z);
if(tag == )
printf("No\n");
else printf("Yes\n");
}
cin >> N;
return ;
}

总结:
1、题意:将一个位数为偶数的数字分成两半,看看这两半的乘积能不能被原数整除。
2、注意依次取一个数的各个位,得到的数组中是倒着的,由高位到低位。
2、在验证能否整除时,要注意被除数为0的情况。如1000被分成10和00.

A1132. Cut Integer的更多相关文章

  1. 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 ...

  2. PAT甲级——A1132 Cut Integer

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

  3. PAT_A1132#Cut Integer

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

  4. PAT1132: Cut Integer

    1132. Cut Integer (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Cutting a ...

  5. PAT 1132 Cut Integer

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

  6. PAT 1132 Cut Integer[简单]

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

  7. 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 ...

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

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

  9. PAT 甲级 1132 Cut Integer

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

随机推荐

  1. 在linux上安装spark详细步骤

    在linux上安装spark ,前提要部署了hadoop,并且安装了scala. 提君博客原创 对应版本 >>提君博客原创  http://www.cnblogs.com/tijun/   ...

  2. Oracle 中sql文件的导入导出

    导出 一般导入的时候我用的是命令行 imp c##zs/@orcl fromuser=c##zs touser=c##zs file=D:\java\.dmp ignore=y c##zs 是创建的用 ...

  3. mycat - 水平分表

    相对于垂直拆分的区别是:垂直拆分是把不同的表拆到不同的数据库中,而水平拆分是把同一个表拆到不同的数据库中.水平拆分不是将表的数据做分类,而是按照某个字段的某种规则来分散到多个库之中,每个表中包含一部分 ...

  4. postman+jenkins+newman自动化api接口测试

    一.下载nodejs https://nodejs.org/zh-cn/download/ 二.linux下解压 xz -d node-v8.11.3-linux-x64.tar.xz tar xf ...

  5. 关于WPF中Popup中的一些用法的总结

    Popup控件是一个常用的非常有用的控件,顾明思义就是弹出式控件,首先我们来看看MSDN对它的解释吧,表示具有内容的弹出窗口,这个是非常重要的控件,我们看看它的继承关系吧: System.Object ...

  6. 安装使用阿里云的yum源

    CentOS 1.备份(备份本地Yum源) mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 2.下 ...

  7. git在实际开发中的应用

    PS: git操作实例(https://learngitbranching.js.org/?demo) 一, 创建分支,合并分支到master 1. 在远程仓库中创建master和test分支 2.本 ...

  8. flask Django保存session区别

    '''Django中,session保存在服务端的数据库中,数据库中保存请求用户的所有数据,服务端数据中{'随机字符串':加密后的客户相关信息}请求完成后,把随机字符串作为值,返回给客户端,保存在客户 ...

  9. vue 子组件修改父组件传来的props值,报错

    vue不推荐直接在子组件中修改父组件传来的props的值,会报错 [Vue warn]: Avoid mutating a prop directly since the value will be ...

  10. HTML中文本过长时自动隐藏末尾部分或中间等任意部分

    一.    一般情况下,HTML字符串过长时都会将超过的部分隐藏点,方法如下: 设置CSS: .ellipsis-type{ max-width: 50px;                      ...