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. 记录SSM框架项目迁移SpringBoot框架-----pom.xml的迁移

    第一步:迁移pom.xml文件(去除spring相关的依赖) SSM中的pom: <project xmlns="http://maven.apache.org/POM/4.0.0&q ...

  2. scrapy架构简介

    一.scrapy架构介绍 1.结构简图: 主要组成部分:Spider(产出request,处理response),Pipeline,Downloader,Scheduler,Scrapy Engine ...

  3. python学习笔记(10)--组合数据类型(序列类型)

    序列是具有先后关系的一组数据,是一维元素向量,元素类型可以不同,类似数学元素序列,元素间由序号引导,通过下标访问序列的特定元素.序列类型是一个基类类型,字符串类型,元祖类型,列表类型都属于序列类型. ...

  4. AI算法第一天【概述与数学初步】

    1. 机器学习的定义: 机器从数据中学习出规律和模式,以应用在新数据上作出预测的任务 2.学习现象: (1)语言文字的认知识别 (2)图像,场景,物体的认知和识别 (3)规则:下雨天要带雨伞 (4)复 ...

  5. PHPStorm 配置命名空间

    文件-设置-Directories 选中:application     点击顶部:Sources,右侧会出现 Source Floders 配置项 点击:p进行设置 输入app\

  6. Python——Entry、Text控件

    background(bg)  : 文本框背景色:  foreground(fg)    :    前景色: selectbackground :  选定文本背景色:  selectforegroun ...

  7. Codeforces Round #545 Div1 题解

    Codeforces Round #545 Div1 题解 来写题解啦QwQ 本来想上红的,结果没做出D.... A. Skyscrapers CF1137A 题意 给定一个\(n*m\)的网格,每个 ...

  8. 【UOJ#246】套路(动态规划)

    [UOJ#246]套路(动态规划) 题面 UOJ 题解 假如答案的选择的区间长度很小,我们可以做一个暴力\(dp\)计算\(s(l,r)\),即\(s(l,r)=min(s(l+1,r),s(l,r- ...

  9. JS基本类型-引用类型-深浅拷贝

    在JavaScript中变量包含两种类型的值:一种是基本类型,一种是引用类型. 基本类型包括:数值.字符串.null.undefined.布尔值引用类型包括:对象.数组.函数.正则… 补充: null ...

  10. CSS居中的几种方式总结

    1.水平居中的 margin:0 auto; 这个是用于子元素上的,前提是不受float影响 <style type="text/css"> .box{ width: ...