1132. Cut Integer (20)
Cutting an integer means to cut a K digits long 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 x 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 <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
int coun(int d)
{
int c = ;
while(d)
{
c ++;
d /= ;
}
return c;
}
int main()
{
int n,d;
scanf("%d",&n);
while(n --)
{
scanf("%d",&d);
int s = coun(d),p = ;
s /= ;
for(int i = ;i < s;i ++)
p *= ;
s = (d/p)*(d%p);///如果是0不能做取模
if(s && d % s == )printf("Yes\n");
else printf("No\n");
}
}
1132. Cut Integer (20)的更多相关文章
- 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 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(20 分)
1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...
- 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 甲级 1132 Cut Integer
https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...
- 1132 Cut Integer
题意:略. 思路:注意除数可能为0的情况,不然会导致浮点错误. 代码: #include <iostream> #include <string> using namespac ...
- PAT1132: Cut Integer
1132. Cut Integer (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Cutting a ...
- PAT_A1132#Cut Integer
Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone in ...
- PAT-1132(Cut Integer )数的拆分+简单题
Cut Integer PAT-1132 #include<iostream> #include<cstring> #include<string> #includ ...
随机推荐
- Javascript 中 == 与=== 对比
首先,== equality 等同,=== identity 恒等. ==, 两边值类型不同的时候,要先进行类型转换,再比较. ===,不做类型转换,类型不同的一定不等. 下面分别说明: 先说 === ...
- FTP pure-ftpd 安装、管理
FTP简介 FTP是File Transfer Protocol(文件传输协议)的英文简称,而中文简称为文传协议,用户Internet上的控制文件的双向传输. FTP的主要作用,就是让用户链接上一个远 ...
- Nginx rewrite配置
rewrite应用 Rewrite模块设置及Wordpress和Discuz的示例.Nginx的Rewrite规则比Apache的简单灵活多了,从下面介绍可见一斑. rewrite配置 Nginx可以 ...
- H5中的语义化标签
H5中的语义化标签也就是之前的id = “header”演变而来的 只不过之前是id 现在变成了标签而已 什么是语义化: 根据内容结构化(内容语义化) 选择合适的标签(代码语义化) 便于开发者阅读和写 ...
- 会话控制Cookie的应用
Cookie是一种由服务器发送给客户端的片段信息,存储在客户端浏览器的内存或者硬盘上,在客户端对服务器的请求中发回它.PHP透明地支持HTTP Cookie.可以利用他在远程浏览器端存储数据并以此来跟 ...
- MessageFormat与占位符使用
占位符替换,花括号中为索引占位,对应可变参数后面的值 String pattern = "ErrorMessage=This is Error Message : {0},{1}" ...
- ES6 Babel 简单使用
ECMAScript 是 JS 的语言标准.而 ES6 是新的 JS 语法标准. PS:严格来说,ECMAScript 还包括其他很多语言的语言标准. ECMAScript 发展历史 1995年:EC ...
- bzoj 2190: [SDOI2008]仪仗队 线性欧拉函数
2190: [SDOI2008]仪仗队 Time Limit: 10 Sec Memory Limit: 259 MB[Submit][Status][Discuss] Description 作为 ...
- 使用SpringMVC时报错HTTP Status 405 - Request method 'GET' not supported
GET方法不支持.我出错的原因在于,在JSP中我希望超链接a以post方式提交,但是这里写js代码时出错. <script type="text/javascript"> ...
- [javascript]JS如何获取当前时间戳
[javascript]JS如何获取当前时间戳 一.总结 一句话总结:var timestamp = Date.parse(new Date()); 结果是带三位毫秒的,再除个1000取整即可 1.j ...