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 ...
随机推荐
- Cocos Creator实现1024游戏,免费提供代码。
效果预览 获取代码 私信或留言. 游戏介绍 ● Github上的代码,不能进行合并操作,修改以后,功能类似2048,空白块赏随机位置,生成2,可以往左.右.上.下滑动,数字会朝着指定方向运动,相 ...
- 2019.10.26 CSP%您赛第三场
\(CSP\)凉心模拟^_^ --题源\(lqx.lhc\)等各位蒟蒻 题目名称 比赛 传递消息 开关灯 源文件名 \(competition.cpp\) \(message.cpp\) \(ligh ...
- Exception evaluating SpringEL expression:
Exception evaluating SpringEL expression:错误 说明: 在帮助同事看BUG的时候遇上了这个问题,不知道是前端还是后端的错误 在网上找了很多文章解决的方法,很多都 ...
- Webpack打包css后z-index被重新计算的解决方法
发现问题 最近在使用 Webpack 打包 css 文件时,发现了一个问题,发现打包后的 z-index 值跟源文件 z-index 不一致. 如下图,左侧是源文件,右侧是打包后的文件: 即使加上 ! ...
- C++两个队列实现一个栈
C++两个队列实现一个栈 /* * source.cpp * * Created on: 2015年6月21日 * Author: codekiller */ #include "iostr ...
- 【Windows系统】win10系统假死,窗口不能动,鼠标能动或不能动,最后蓝屏显示错误码: VIDEO_DXGKRNL_FATAL_ERROR 的解决办法
1. 问题的出现过程 最近博主自己用的 windows10 系统就碰到了这个问题. 一开始出现这个问题的征兆是鼠标会时不时地卡顿,一出现卡顿就会等个 1-3秒才能动.然后频繁卡顿(注意,这里根据经验就 ...
- Java中 实体类 VO、 PO、DO、DTO、 BO、 QO、DAO、POJO的概念
PO(persistant object) 持久对象 在 o/r 映射的时候出现的概念,如果没有 o/r 映射,没有这个概念存在了.通常对应数据模型 ( 数据库 ), 本身还有部分业务逻辑的处理.可以 ...
- 深入理解大数据架构之——Lambda架构
目录 传统系统的问题 Lambda架构简介 Lambda架构关键特性 数据系统的本质 Lambda的三层架构 Lambda架构组件选型 总结 原文链接:https://jiang-hao.com/ar ...
- 博客文章编辑器 Cmd Markdown
欢迎使用 Cmd Markdown 编辑阅读器 编辑器点击打开链接 学习语言地址点击打开链接
- 上下文管理器及with的相关总结
什么是上下文管理器 基本语法 with EXPR as VAR: BLOCK 概念 上下文表达式:with open('test.txt') as f: 上下文管理器:open('test.txt') ...