1132 Cut Integer (20 分)
 

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的更多相关文章

  1. PAT 1132 Cut Integer[简单]

    1132 Cut Integer(20 分) Cutting an integer means to cut a K digits lone integer Z into two integers o ...

  2. 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 ...

  3. PAT 甲级 1132 Cut Integer

    https://pintia.cn/problem-sets/994805342720868352/problems/994805347145859072 Cutting an integer mea ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 1132 Cut Integer

    题意:略. 思路:注意除数可能为0的情况,不然会导致浮点错误. 代码: #include <iostream> #include <string> using namespac ...

  8. PAT1132: Cut Integer

    1132. Cut Integer (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Cutting a ...

  9. PAT_A1132#Cut Integer

    Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone in ...

随机推荐

  1. 教你如何修改运行中的docker容器的端口映射

    在docker run创建并运行容器的时候,可以通过-p指定端口映射规则.但是,我们经常会遇到刚开始忘记设置端口映射或者设置错了需要修改.当docker start运行容器后并没有提供一个-p选项或设 ...

  2. week1 - Python基础1 介绍、基本语法、流程控制

    知识内容: 1.python介绍 2.变量及输入输出 3.分支结构 4.循环结构 一.python介绍 Python主要应用领域: 云计算: 云计算最火的语言, 典型应用OpenStack WEB开发 ...

  3. python & mysql 操作(compare_sum_fee)

    [1]源码 工作中涉及的python工具源码实现 费用比较工具源码: #!/usr/bin/python3 #coding = utf-8 import time, sqlite3, datetime ...

  4. /bin, /sbin & /usr/bin, /usr/sbin & /usr/local/bin, /usr/local/sbin & glibc

    操作系统为自身完成启动所需要的 /bin, /sbin 系统基本管理所需要的 /usr/bin, /usr/sbin 第三方的 /usr/local/bin, /usr/local/sbin 核心库 ...

  5. Centos7下安装配置elasticsearch 6.3.1

    1)下载 Elasticsearch 6.3.1 地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1 ...

  6. SynchronousQueueDemo

    1.ArrayDeque, (数组双端队列) 2.PriorityQueue, (优先级队列) 3.ConcurrentLinkedQueue, (基于链表的并发队列) 4.DelayQueue, ( ...

  7. webservice常用两种身份验证方式

    在项目开发,我们经常会使用WebService,但在使用WebService时我们经常会考虑以下问题:怎么防止别人访问我的WebService?从哪里引用我的WebService?对于第一个问题,就涉 ...

  8. 破圈法求解最小生成树c语言实现(已验证)

    破圈法求解最小生成树c语言实现(已验证) 下面是算法伪代码,每一个算法都取一个图作为输入,并返回一个边集T. 对该算法,证明T是一棵最小生成树,或者证明T不是一棵最小生成树.此外,对于每个算法,无论它 ...

  9. TeamCity Agent安装

    1 docker安装 docker run -it -e SERVER_URL= \ -v /home/lishan/teamcity/conf:/data/teamcity_agent/conf \ ...

  10. 原创《分享(Angular 和 Vue)按需加载的项目实践优化方案》

    针对前端优化的点有很多,例如:图片压缩,雪碧图,js/css/html 文件的压缩合并,  cdn缓存, 减少重定向, 按需加载 等等 最近有心想针对 ionic项目 和 vue项目,做一个比较大的优 ...