首页 > 其他分享 >1132 Cut Integer(附测试点浮点错误)

1132 Cut Integer(附测试点浮点错误)

时间:2023-09-14 16:44:40浏览次数:53  
标签:Cut 测试点 No int 1132 num 167334 each 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 <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

 

易错:

c++运算符优先级 !的优先级比%大   https://blog.csdn.net/nicky_zs/article/details/4053146 

浮点错误:要注意除数为0的情况

 

代码:

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int z, t, num = 0;
        scanf("%d", &z);
        t = z; 
        while(t != 0){
            t /= 10;
            num++;
        }
        int w = 1;
        for(int j = 0; j < num / 2; j++){
            w *= 10;
        }
        int a = z / w;
        int b = z % w;
        int c = a * b;
        if(c != 0 && z % c == 0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

 

标签:Cut,测试点,No,int,1132,num,167334,each,integer
From: https://www.cnblogs.com/yccy/p/17702854.html

相关文章

  • 安装系统出现dracut-initqueue timeout
    dracut-initqueuetimeout因为系统安装的时候默认的读取不到U盘的数据,需要手动指定。两种解决办法:出来install的界面之后,按e进入编辑界面,将原来第一行的内容改成:vmlinuzinitrd=initrd.imglinuxddnomodesetquiet第二行不变,然后ctrl+x执行,执行完之后能看到电脑所有的硬......
  • ExecutorService VS Timer
    IhavecodewhereIscheduletaskusingjava.util.timer.IwaslookingaroundandsawExecutorServicecandothesame.Sothisquestionhere,haveyouusedTimerandExectuorServicetoscheduletasks,whatisthebenefitofoneusing......
  • Java多线程____Executors线程池的使用和架构原理
    1.线程池API类型1.创建一个可重用固定线程数的线程池packagecom.frame.base.thread;importjava.util.concurrent.Executors;importjava.util.concurrent.ExecutorService;/***Java线程:线程池*@authorAdministrator*/publicclassTestExecutors{ publicstati......
  • BUG库(Maven)Failed to execute goal org.apache.maven.plugins:maven-surefire-plugi
    一.Maven打包失败1.场景-项目中打包执行测试类报错 Failedtoexecutegoalorg.apache.maven.plugins:maven-surefire-plugin:2.12.4:test二.解决方案1.idea工具跳过选择按钮2.在pom文件中添加插件<plugin><groupId>org.apache.maven.plugins</groupId><artifactI......
  • 计算机视觉算法中的GrabCut图像分割(GrabCut Image Segmentation)
    计算机视觉算法中的GrabCut图像分割(GrabCutImageSegmentation)引言图像分割是计算机视觉领域的一个重要任务,它的目标是将图像中的像素分成不同的区域或对象。GrabCut是一种经典的图像分割算法,它基于图割理论和高斯混合模型,能够有效地将图像中的前景和背景进行分离。本文将介绍Grab......
  • 1137 Final Grading(测试点3段错误、答案错误)
    题目:Forastudenttakingtheonlinecourse"DataStructures"onChinaUniversityMOOC(http://www.icourse163.org/),tobequalifiedforacertificate,he/shemustfirstobtainnolessthan200pointsfromtheonlineprogrammingassignments,and......
  • xxl-job-executor执行器部署到k8s中时,port报错
    错误:15:48:21.902logback[main]ERRORo.s.boot.SpringApplication-Applicationrunfailedorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname'xxlJobConfig':Unsatisfieddependencyexpressedthroughfie......
  • Java实现关系型数据库工具类JdbcUtils系列九:通用DAO
    Java实现关系型数据库工具类JdbcUtils系列九:通用DAO一、创建对应数据库表的实体类二、数据库连接池Druid工具类三、DAO类四、BaseDAO五、DatabaseInfoDao六、通用DAO测试类一、创建对应数据库表的实体类数据库表结构CREATETABLE`databaseInfo`(`id`bigint(11)NOTNULLAU......
  • 20211325 2023-2024-1 《信息安全系统设计与实现(上)》第一周学习笔记
    202113252023-2024-1《信息安全系统设计与实现(上)》第一周学习笔记一、任务要求任务详情自学教材第1,2章,提交学习笔记(10分),评分标准如下1.知识点归纳以及自己最有收获的内容,选择至少2个知识点利用chatgpt等工具进行苏格拉底挑战,并提交过程截图,提示过程参考下面内容(4分)......
  • delphi FireDAC 调用 Execute 提示 `[FireDAC][SQL Server Native Client 10.0]字符串
    FireDAC调用Execute提示[FireDAC][SQLServerNativeClient10.0]字符串数据,长度不匹配错误问题调用Execute向SQLServer数据库中批量插入数据时,参数中有BLOB数据类型(ftBlob、ftMemo等)时,出现[FireDAC][Phys][ODBC][Microsoft][SQLServerNativeClient10.0]字符串......