pat 1132 Cut Integer(20 分)
1132 Cut Integer(20 分)
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 <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
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
#define wzf ((1 + sqrt(5.0)) / 2.0)
#define INF 0x3f3f3f3f
#define LL long long
using namespace std; const int MAXN = 2e3 + ; int t, Z, A, B, len, temp; char s[MAXN]; int my_pow(int x, int n)
{
int ans = ;
while (n)
{
if (n & ) ans *= x;
x *= x;
n >>= ;
}
return ans;
} int main()
{
scanf("%d", &t);
while (t --)
{
Z = A = B = 0L;
scanf("%s", &s); len = strlen(s), temp = len >> ;
for (int i = , j = len - ; i < len; ++ i, -- j)
Z += (int)(s[i] - '') * my_pow(, j);
for (int i = , j = temp - ; i < temp; ++ i, -- j)
A += (int)(s[i] - '') * my_pow(, j);
for (int i = temp, j = temp - ; i < len; ++ i, -- j)
B += (int)(s[i] - '') * my_pow(, j); if ((A * B) != && Z % (A * B) == ) printf("Yes\n");
else printf("No\n");
}
return ;
}
pat 1132 Cut Integer(20 分)的更多相关文章
- 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 Advanced 1132 Cut Integer (20) [数学问题-简单数学]
题目 Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long ...
- 1132. Cut Integer (20)
Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long int ...
- pat 1035 Password(20 分)
1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- pat 1077 Kuchiguse(20 分) (字典树)
1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal ...
- pat 1008 Elevator(20 分)
1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...
- PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Person ...
随机推荐
- [BZOJ29957] 楼房重建 - 线段树
2957: 楼房重建 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 3294 Solved: 1554[Submit][Status][Discus ...
- (21)ASP.NET Core EF创建模型(关系)
1.关系 关系定义两个实体之间的关系.在关系型数据库中,这由外键约束表示. 2.术语定义 有许多术语用于描述关系:●相关实体:这是包含外键属性的实体.有时称为关系的"子级".●主体 ...
- 一张图看懂Rxjava的原理
前言 Rxjava是NetFlix出品的Java框架, 官方描述为 a library for composing asynchronous and event-based programs usin ...
- Halcon C# 联合编程问题(三)
因为之前遇到的那个halcon处理的图片要转换成ImageSource的问题,迟迟没有找到好的解决方案, 于是决定直接在wpf中使用halcon提供的HWindowControlWPF,用于显示图片. ...
- VSCode 安装 code 命令
VSCode 提供 code 命令直接从命令行中打开文件目录,此时需要先安装 code 命令. 1.首先打开 VSCode 2.使用 command + shift + p (注意window 下使用 ...
- Qualcomm-Atheros-QCA9377-Wifi-Linux驱动
资源来自:https://download.csdn.net/download/ichdy/10331646 已经下载好了,发现无法使用,本人系统Centos7.2,如果有安装成功,并且可以正常使用的 ...
- 远程桌面连接(mstsc)
目录 1. 序言 2. 准备工作 3. 内网远程连接(以mstsc的方式) 4. 问题---凭据不工作 5. 外网远程连接(mstsc) 6. 结语 更新时间:2019.09.10 1. 序言 有时候 ...
- 2019.NET Conf,我们在共同期待
(一)回顾一个小社区红过的五分钟 不知不觉,距离中国.net社区组织的.net conf只有不到一周的时间,还记得年初在叶伟民老师,潘淳老师和张善友老师的号召下,我们长沙的十几位开发者自发组织起来,拉 ...
- 2019 年容器生态统计报告发布 | 云原生生态周报 Vol. 26
作者 | 酒祝.天元.元毅.心水.衷源 业界要闻 1.2019 年容器生态统计报告发布 据报告显示,Kubernetes 占据 77% 的容器编排产品份额,Docker 占据 79% 的容器引擎产品 ...
- 转:PHP删除目录及目录下所有文件
PHP删除目录及目录下所有文件 <?php //循环删除目录和文件函数 function delDirAndFile( $dirName ) { if ( $handle = opendir( ...