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 <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的更多相关文章
- 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 ...
- 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 ...
- PAT_A1132#Cut Integer
Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone in ...
- PAT1132: Cut Integer
1132. Cut Integer (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Cutting a ...
- PAT 1132 Cut Integer
1132 Cut Integer (20 分) Cutting an integer means to cut a K digits lone integer Z into two integer ...
- PAT 1132 Cut Integer[简单]
1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...
- 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 ...
- PAT-1132(Cut Integer )数的拆分+简单题
Cut Integer PAT-1132 #include<iostream> #include<cstring> #include<string> #includ ...
- PAT 甲级 1132 Cut Integer
https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...
随机推荐
- Day 4-4 shutil模块
常用方法: import shutil f = open("conf.ini", "r") f1 = open("shutil.ini", ...
- Python 基础之----网络编程
阅读目录 一 客户端/服务端架构 二 osi七层 三 socket层 四 socket是什么 五 套接字发展史及分类 六 套接字工作流程 七 基于TCP的套接字 八 基于UDP的套接字 九 粘包现象 ...
- MVC最全jar包
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> & ...
- laravel5.3安装redis扩展包
1,编辑 laravel 根目录下的 composer.json 文件: "require": { "php": ">=5.6.4", ...
- X5中CSS设置
颜色渐变 position:absolute;left:0;top:40%; 效果图 点击导航按钮变化颜色 1.设置按钮class为 btn-link(超链接) 2.为每一个导航按钮增加属性id 3. ...
- Yii2上传图片插件使用
例子: 1.在表单中: <?php $form = \yii\widgets\ActiveForm::begin([ 'options'=>[ 'class' => 'form-ho ...
- vue循環語句
迭代數組: v-for="site in sites”,sites表示源數組名,site表示數組元素: 迭代對象: v-for=“value in Object”, v-for=" ...
- 二、两条Linux删除数据跑路命令
一.rm rm -rf / 无提示循环删除根目录,,删除存在被恢复的可能 二.dd dd if=/dev/urandom of=/dev/hda1 随机填写数据到相应分区,直到填满为止.重写后的分区无 ...
- Python 第三方库 cp27、cp35 等文件名的含义(转)
转自 https://blog.csdn.net/lanchunhui/article/details/62417519 转自 https://stackoverflow.com/questions/ ...
- Maven依赖范围及传递
.Maven因为执行一系列编译.测试和部署运行等操作,在不同的操作下使用的classpath不同,依赖范围就是用来控制依赖与三种 classpath(编译classpath.测试classpath.运 ...