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 <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 <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 分)的更多相关文章

  1. PAT 1132 Cut Integer

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

  2. PAT 1132 Cut Integer[简单]

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

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

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

  5. pat 1035 Password(20 分)

    1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...

  6. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  7. pat 1077 Kuchiguse(20 分) (字典树)

    1077 Kuchiguse(20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  8. pat 1008 Elevator(20 分)

    1008 Elevator(20 分) The highest building in our city has only one elevator. A request list is made u ...

  9. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

随机推荐

  1. 数据挖掘:python数据清洗cvs里面带中文字符

    数据清洗,使用python数据清洗cvs里面带中文字符,意图是用字典对应中文字符,即key值是中文字符,value值是index,自增即可:利用字典数据结构没有重复key值的特性,把中文字符映射到了数 ...

  2. PHP 奇葩的debug_zval_dump的输出

    有段代码: $a1 = 'Hello world!'; $a2 = &$a1; echo "test1 :"; debug_zval_dump($a1); $b1 = 'H ...

  3. [JOYOI1510] 专家复仇 - Floyd

    题目限制 时间限制 内存限制 评测方式 题目来源 1000ms 131072KiB 标准比较器 Local 题目背景 外星人完成对S国的考察后,准备返回,可他们的飞碟已经没燃料了……S国的专家暗自窃喜 ...

  4. textView 实现完成收键盘操作

    -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSStr ...

  5. java中多线程 - 多线程中的基本方法

    介绍一下线程中基本的方法使用 线程睡眠sleep() Thread.sleep(毫秒);我们可以通过sleep方法设置让线程睡眠.可以看到sleep是个静态方法 public static nativ ...

  6. Java基础(一)对象构造

    由于Java对象构造非常重要,所以Java提供了多种编写构造器的机制. 1.重载 如果多个方法有相同的名字.不同的参数,便产生了重载.编译器必须挑选出具体执行哪个方法,它通过用各个方法给出的参数类型与 ...

  7. 消息中间件-RabbitMQ环境搭建

    一直在传统行业工作(早九晚五不加班),没有考虑消息中间件的性能,所以一直再用activeMQ也没有想过学习别的中间件,时间长也没什么技术上的进步,而且感觉到了 工作的麻木,所以决定学一些新的技术(其实 ...

  8. 消息队列 ActiveMQ 、RocketMQ 、RabbitMQ 和 Kafka 如何选择?

    「 预计阅读 6 分钟 」 旁白:这是一篇拖更了N久的文章...0.0(看不见我~) 往期回顾 前端框架 jQuery 和 Vue 如何选择? 安全框架 Shiro 和 Spring Security ...

  9. 搭建邮件服务器,使用Postfix与Dovecot收发电子邮件

    小知识: 我们为什么要搭建邮件服务器呢?有时候我们处于一个局域网内,不能及时的分享各自的研究成果,迫切的需要一种能够借助于网络且建立在计算机之间的传输数据的方法.所以我们需要搭建邮件服务器,这样的话既 ...

  10. 学习笔记62_python文件操作

    #使用 str = raw_input("输入密码:") 来获取键盘的输入 #创建或打开一个文件 fp = open("hellow.txt","w& ...