PAT1132: Cut Integer
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 思路
水题
1.首先如果输入的数Z的位数为奇数肯定不满足条件,输出No。
2.如果A乘B为0,肯定不满足条件,输出No
3.剩下情况检查Z % (A*B) 是否为0即可。
代码
#include<iostream>
#include<string>
using namespace std;
int main()
{
int N;
while(cin >> N)
{
while(N--)
{
string num;
cin >> num;
int len = num.size();
if(len % == )
{
cout << "No" << endl;
continue;
} string a = num.substr(,len/);
string b = num.substr(len/,len/);
int A = stoi(a),B = stoi(b),Z = stoi(num);
if(A * B != && Z % (A * B) == )
{
cout << "Yes" << endl;
}
else
cout << "No" << endl; }
}
}
最新文章
- C#操作SQLite数据库
- 安卓,支付宝app登录时,提示 服务器安全证书已过期或不可信任,请问怎么解决
- App上架审核指南翻译
- erl_0013 erlang 带参数模块 parameterized modules are no longer supported
- SQL Server 2008 数据库误删除数据的恢复
- sqlserver 遇到以零作除数错误的处理 不报错的解决方法
- MIT 操作系统实验 MIT JOS lab2
- CENTOS下Python 升级后YUM无法使用的解决办法
- HTTP协议类
- Selenium+Chrome/phantomJS模拟浏览器爬取淘宝商品信息
- jdk源码阅读笔记-LinkedList
- python数据可视化
- LeetCode 500 Keyboard Row 解题报告
- 微信小程序支付签名老是失败,在官网的校验签名工具校验成功,老是返回签名失败
- spring的IOC 的底层实现原理
- GIT与VCS
- js:二级联动示例
- CSS学习摘要-定位
- CodeForces - 589D —(思维题)
- [CQOI2009] 中位数 (前缀和)
热门文章
- 【Unity插件】LitJson杂谈
- Robust Locally Weighted Regression 鲁棒局部加权回归 -R实现
- 实用Android 屏幕适配方案分享
- Java-clone总结
- XWork容器的存储结构
- Customer Form Issue: Automatic Matching Rule Set Defaults Value AutoRuleSet-1
- Linux常用命令(第二版) --压缩解压缩命令
- React Native Android开发环境配置
- SpringBoot的第一个例子
- HashMap实现原理及源码分析(JDK1.7)