PAT甲级——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 <). 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 <string>
using namespace std;
int main()
{
int n, num, a, b;
cin >> n;
while (n--)
{
string str, str1, str2;
cin >> str;
str1.assign(str.begin(), str.begin() + str.length() / );
str2.assign(str.begin() + str.length() / , str.end());
num = atoi(str.c_str());
a = atoi(str1.c_str());
b = atoi(str2.c_str());
if ((a*b) > && num % (a*b) == )
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return ; }
PAT甲级——A1132 Cut Integer的更多相关文章
- PAT 甲级 1132 Cut Integer
https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...
- 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 ...
- 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 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 ...
- 【PAT甲级】1113 Integer Set Partition (25分)
题意: 输入一个正整数N(2<=N<=1e5),接着输入N个正整数,将这些数字划分为两个不相交的集合,使得他们的元素个数差绝对值最小且元素和差绝对值最大. AAAAAccepted cod ...
- 【PAT甲级】1103 Integer Factorization (30 分)
题意: 输入三个正整数N,K,P(N<=400,K<=N,2<=P<=7),降序输出由K个正整数的P次方和为N的等式,否则输出"Impossible". / ...
- PAT_A1132#Cut Integer
Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone in ...
- PAT甲级1103. Integer Factorization
PAT甲级1103. Integer Factorization 题意: 正整数N的K-P分解是将N写入K个正整数的P次幂的和.你应该写一个程序来找到任何正整数N,K和P的N的K-P分解. 输入规格: ...
- PAT 1132 Cut Integer
1132 Cut Integer (20 分) Cutting an integer means to cut a K digits lone integer Z into two integer ...
随机推荐
- openwrt usb
fdisk -l #以列表的形式,列出当前挂载盘的情况 for 属性规定 label 与哪个表单元素绑定 <form> <label for="male"> ...
- C++:查找字符串字串并替换
string a;/////指定串,可根据要求替换 string b;////要查找的串,可根据要求替换 string c; cin>>a>>b>>c; int p ...
- JavaScript中的函数柯里化与反柯里化
一.柯里化定义 在计算机科学中,柯里化是把 接受多个参数的函数 变换成 接受一个单一参数(最初函数的第一个参数)的函数 并且返回 接受余下参数且返回结果的新函数的技术 高阶函数 高阶函数是实现柯里化的 ...
- NX二次开发-算法篇-判断找到两个数组里不相同的对象
NX9+VS2012 #include <uf.h> #include <uf_curve.h> #include <uf_modl.h> #include < ...
- NX二次开发-删除经典工具栏UF_UI_remove_toolbar
NX9+VS2012 1.打开D:\Program Files\Siemens\NX 9.0\UGII\menus\ug_main.men 找到装配和PMI,在中间加上一段 TOGGLE_BUTTON ...
- [Python]PDF合成小程序PDF合成小程序
运行平台:Python3.5 用刀了PyPDF2这个库,需要提前下载好. 源码如下: import PyPDF2, os #建立一个装pdf文件的数组pdfFiles = [] for fileNam ...
- 2. Vim 概念扫盲
Frm: http://www.linuxidc.com/Linux/2013-05/84031p2.htm 了解Vim的三个基本模式 当我们安装完一个编辑器后,肯定会打开它,然后在里面输入点什么东西 ...
- 尾插法-实现链表反转(有点bug,以后再来研究下)
def func2(head): p = head.next while p.next: q = p.next p.next = q.next # 重点 head.next = q q.next = ...
- 20140316 window live write 插件 推荐代码高亮插件 构造函数只能用初始化成员列表方式的例子
1.window live write 插件:http://www.cnblogs.com/liuxianan/archive/2013/04/13/3018732.html 2.推荐代码高亮插件:W ...
- SSM项目配置文件DEMO
SSM相关配置文件 <spring-mvc.xml>文件 <?xml version="1.0" encoding="UTF-8"?> ...