1132. Cut Integer (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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; }
}
}

最新文章

  1. C#操作SQLite数据库
  2. 安卓,支付宝app登录时,提示 服务器安全证书已过期或不可信任,请问怎么解决
  3. App上架审核指南翻译
  4. erl_0013 erlang 带参数模块 parameterized modules are no longer supported
  5. SQL Server 2008 数据库误删除数据的恢复
  6. sqlserver 遇到以零作除数错误的处理 不报错的解决方法
  7. MIT 操作系统实验 MIT JOS lab2
  8. CENTOS下Python 升级后YUM无法使用的解决办法
  9. HTTP协议类
  10. Selenium+Chrome/phantomJS模拟浏览器爬取淘宝商品信息
  11. jdk源码阅读笔记-LinkedList
  12. python数据可视化
  13. LeetCode 500 Keyboard Row 解题报告
  14. 微信小程序支付签名老是失败,在官网的校验签名工具校验成功,老是返回签名失败
  15. spring的IOC 的底层实现原理
  16. GIT与VCS
  17. js:二级联动示例
  18. CSS学习摘要-定位
  19. CodeForces - 589D —(思维题)
  20. [CQOI2009] 中位数 (前缀和)

热门文章

  1. 【Unity插件】LitJson杂谈
  2. Robust Locally Weighted Regression 鲁棒局部加权回归 -R实现
  3. 实用Android 屏幕适配方案分享
  4. Java-clone总结
  5. XWork容器的存储结构
  6. Customer Form Issue: Automatic Matching Rule Set Defaults Value AutoRuleSet-1
  7. Linux常用命令(第二版) --压缩解压缩命令
  8. React Native Android开发环境配置
  9. SpringBoot的第一个例子
  10. HashMap实现原理及源码分析(JDK1.7)