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 ...
随机推荐
- 【FJWC2018】最大真因数
题面 Description 一个合数的真因数是指这个数不包括其本身的所有因数, 例如 6 的正因数有1, 2, 3, 6,其中真因数有 1, 2, 3. 一个合数的最大真因数则是这个数的所有真因数中 ...
- Redis探索之路(四):Redis的五种数据类型Set和ZSet
一:Set无需集合 Set是个集合,string类型的无需集合,通过hash table实现,添加删除查找复杂度都是0(1).对集合我们可以取并集,交集和差集.通过这些操作我们可以实现sns中的好友推 ...
- js简单图片切换
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title> ...
- Python ORM封装
import sys import asyncio import logging logging.basicConfig(level=logging.INFO) # 一次使用异步 处处使用异步 imp ...
- 安装zabbix需求环境
yum install gcc gcc-c++ make mysql-server mysql-devel libcurl-devel net-snmp-devel php php-ldap php- ...
- 创建 Angular 8.0 项目
创建 Angular 8.0 项目,首先确保已经安装了 nodejs,如果没有安装,请看这篇文章安装:node.js 安装 1.新建一个空文件夹 angularproject,作为工作区 2.安装 A ...
- RN相关命令
添加第三方库 npm install --save xxx react-native link 链接库 react-native react-native -v 查看RN版本 npm info re ...
- chomp
用来除去最后的换行等空白字符. 例程: #!/usr/bin/perl #chomp.pl use warnings; use strict; print "Input a string & ...
- Codeforces 1176A Divide it!
题目链接:http://codeforces.com/problemset/problem/1176/A 思路:贪心,对第二个操作进行俩次等于将n变成n/3,第三个操作同理,我们将n不断除以2,再除以 ...
- ECMAScript1.4 对象 | 简单数据类型与复杂数据类型 | 内置对象 | 基本包装类型 | String
对象 函数和对象的区别: 函数:封装代码 对象:封装属性和方法 创建对象的方法: 1,对象字面量{} // 模拟创建一只dog var dog = { // 属性 name: 'puppy', age ...