PAT 1132 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<bits/stdc++.h>
using namespace std;
typedef long long ll; ll to_ll(string s){
ll sum = ;
for(int i=;i < s.size();i++){
sum = sum* + (s[i] - '');
}
return sum;
} int main(){ int t;
cin >> t;
while(t--){
string s;
cin >> s;
string s1 = s.substr(,s.size()/);
string s2 = s.substr(s.size()/,s.size()/);
ll num1 = to_ll(s1);
ll num2 = to_ll(s2);
ll num = to_ll(s);
if(num2 == ||num1 == ) {
printf("No\n");
continue;
}
if(num%num1 == ){
num = num/num1;
if(num%num2 == ) printf("Yes\n");
else printf("No\n");
}
else printf("No\n");
} return ;
}
浮点错误: 您的程序运行时发生浮点错误,比如遇到了除以 0 的情况
所以发生浮点错误应该考虑程序中:
- 是否可能出现了一个数除以0的情况
- 是否可能出现了一个数取余0的情况
- 是否发生了数据溢出而导致的除以0或者取余0的情况
PAT 1132 Cut Integer的更多相关文章
- 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(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
https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...
- 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 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 ...
- 1132. Cut Integer (20)
Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long int ...
- 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 ...
随机推荐
- RSA 汇总
最近工作中遇到了RSA,这个,以前只是粗略的看了一下,结果,实际使用的时候,各种眼花缭乱啊.现在整理一下RSA有哪些相关知识. 1. RSA算法本身.算法本身的内容实际上是在pkcs#1的标准里面说明 ...
- Log4j2 HelloWorld
Log4j2 使用教程 Log4j2 的好处就不在这里一一列举了,如果你搜了2,说明你对它一定有兴趣,并且想了解它,使用它. 一.下载log4j2 ,基本上你只需要导入下面两个jar包即可: log4 ...
- 2018-2019-2 网络对抗技术 20165305 Exp2 后门原理与实践
常用后门工具 一.Windows获得Linux Shell 在Windows下使用ipconfig查看本机IP 使用ncat.exe程序监听本机的5305端口 在Kali环境下,使用nc指令的-e选项 ...
- python-列表与元组
列表(List) 特性: 列表也是一种Sequence 类型 下标 能切片 可以存储任何类型的数据,每个元素是任意类型,可以存放任 ...
- 2018-2019-2 20165316 『网络对抗技术』Exp3:免杀原理与实践
2018-2019-2 20165316 『网络对抗技术』Exp3:免杀原理与实践 一 免杀原理与实践说明 (一).实验说明 任务一:正确使用msf编码器,msfvenom生成如jar之类的其他文件, ...
- LeetCode9 回文数
题目链接:https://leetcode-cn.com/problems/palindrome-number/ 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数 ...
- 爬坑二 activiti流数据库版本错误引发的问题
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actModelCont ...
- ADO.Net的发展史
1.演变历史: 它们是按照这个时间先后的顺序逐步出现的,史前->ODBC->OLEDB->ADO->ADO.Net. 2.下面分别介绍一下这几个. a. 史前的数据访问是什么样 ...
- Numpy 基础
Numpy 基础 参考https://www.jianshu.com/p/83c8ef18a1e8 import numpy as np 简单创建数组 # 创建简单列表 a = [1, 2, 3, 4 ...
- 将webcam设置为网站favicon
今天在Twitter上看到用户davywtf将webcam设置为网站favicon. 在线示例: https://wybiral.github.io/code-art/projects/tiny-mi ...