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 ...
随机推荐
- 谷歌浏览器报错 Active resource loading counts reached to a per-frame
Active resource loading counts reached to a per-frame limit while the tab is in background. Network ...
- 你不知道的JavaScript——this词法
https://www.cnblogs.com/hutaoer/p/3423782.htmlhttps://www.cnblogs.com/vicky-li/p/8669549.htmlhttps:/ ...
- cordova微信支付回调App闪退
这是cordova版本太高,不兼容这个插件所导致的.解决方案是修改$your_project/plugins/cordova-plugin-wechat/scripts/android-install ...
- 非关系型数据库----MongoDB
一.什么是MongoDB? MongoDB 是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统. 在高负载的情况下,添加更多的节点,可以保证服务器性能. MongoDB 旨在为WEB应用提 ...
- 在浏览器上安装 Vue Devtools工具
Vue.js devtools是基于google chrome浏览器的一款调试vue.js应用的开发者浏览器扩展,可以在浏览器开发者工具下调试代码. 1)首先在github下载devtools源码,地 ...
- Recursive sequence HDU - 5950 (递推 矩阵快速幂优化)
题目链接 F[1] = a, F[2] = b, F[i] = 2 * F[i-2] + F[i-1] + i ^ 4, (i >= 3) 现在要求F[N] 类似于斐波那契数列的递推式子吧, 但 ...
- 使用js主函数的原因是等文档加载完了才给里面的元素添加东西 如果不使用主函数则文档加载时候无法找到元素则不能成功给元素添加事件
使用js主函数的原因是等文档加载完了才给里面的元素添加东西 如果不使用主函数则文档加载时候无法找到元素则不能成功给元素添加事件
- Android 模块化/热修复/插件化 框架选用
概念汇总 动态加载:在程序运行的时候,加载一些程序自身原本不存在的文件并运行这些文件里的代码逻辑.动态加载是热修复与插件化实现的基础. 热修复:修改部分代码,不用重新发包,在用户不知情的情况下,给ap ...
- 微服务配合docker使用
1.docker 安装 rabbitmq 启动脚本: docker run -d --name rabbitmq --publish : \ --publish : --publish : --pub ...
- HDU - 3917(朴素LIS + 最大流)
题意: 求出所有的最长上升子序列的个数且每个元素只能用一次 解析: 呵...呵...呵..呵..emm... 再见 我死了...wa了15发之后...原来不能用~ 要用 != EOF 这题算水题吧. ...