Decimal

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 103    Accepted Submission(s): 49

Problem Description
Given a positive integer n, determine if 1n is an infinite decimal in decimal base. If the answer is yes, print “Yes” in a single line, or print “No” if the answer is no.
 
Input
The first line contains one positive integer T (1 ≤ T ≤ 100), denoting the number of test cases.
For each test case:
Input a single line containing a positive integer n (1 ≤ n ≤ 100).
 
Output
Output T lines each contains a string “Yes” or “No”, denoting the answer to corresponding test case.
 
Sample Input
2
5
3
 
Sample Output
No
Yes

Hint

1/5 = 0.2, which is a finite decimal.
1/3 = 0.333 · · · , which is an infinite decimal.

 
Source

题解:
问1/n是否是有限小数,队友很快反应过来找n是否含有非2和非5的因子。
参考代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
if(n%==)
{
do{
n/=;
}while(n%==);
}
if(n%==)
{
do{n/=;}while(n%==);
}
if(n==) puts("No");
else puts("Yes");
}
return ;
}

2019CCPC秦皇岛D题 Decimal的更多相关文章

  1. 2019CCPC秦皇岛 E题 Escape(网络流)

    Escape Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  2. 2019CCPC秦皇岛I题 Invoker(DP)

    Invoker Time Limit: 15000/12000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  3. 2019ccpc秦皇岛/Gym102361 D - Decimal 签到

    题意: 给定n,判断1/n是否在十进制下无限循环 题解:判断n的是否包含除2,5以外的因数即可 #include<iostream> #include<cstdio> #inc ...

  4. 2019-ccpc秦皇岛现场赛

    https://www.cnblogs.com/31415926535x/p/11625462.html 昨天和队友模拟了下今年秦皇岛的区域赛,,,(我全程在演 题目链接 D - Decimal 签到 ...

  5. 2019CCPC秦皇岛 J MUV LUV EXTRA(KMP)

    MUV LUV EXTRA Time Limit: 2000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)T ...

  6. 2017 CCPC秦皇岛 M题 Safest Buildings

    PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parach ...

  7. 2017 CCPC秦皇岛 L题 One Dimensions Dave

    BaoBao is trapped in a one-dimensional maze consisting of  grids arranged in a row! The grids are nu ...

  8. 2017 CCPC秦皇岛 A题 A Ballon Robot

    The 2017 China Collegiate Programming Contest Qinhuangdao Site is coming! There will be  teams parti ...

  9. 2019CCPC秦皇岛自我反省&部分题解

    练了一年半了,第一次打CCPC,险些把队友坑了打铁,最后也是3题危险捡了块铜. 非常水的点双连通,我居然不相信自己去相信板子,唉,结果整来整去,本来半个小时能出的题,整到了3个小时,大失误呀,不然就可 ...

随机推荐

  1. hdu 5495 LCS (置换群)

    Sample Input231 2 33 2 161 5 3 2 6 43 6 2 4 5 1  Sample Output24 C/C++: #include <map> #includ ...

  2. suseoj 1209: 独立任务最优调度问题(动态规划)

    1209: 独立任务最优调度问题 时间限制: 1 Sec  内存限制: 128 MB提交: 3  解决: 2[提交][状态][讨论版][命题人:liyuansong] 题目描述 用2台处理机A和B处理 ...

  3. 力扣(LeetCode)4的幂 个人题解

    给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方. 示例 1: 输入: 16 输出: true 示例 2: 输入: 5 输出: false 进阶:你能不使用循环或者递归 ...

  4. python:正则1

    鱼c(扩展阅读): Python3 如何优雅地使用正则表达式(详解一) Python3 如何优雅地使用正则表达式(详解二) Python3 如何优雅地使用正则表达式(详解三) Python3 如何优雅 ...

  5. java多线程,多线程加锁以及Condition类的使用

    看了网上非常多的运行代码,很多都是重复的再说一件事,可能对于java老鸟来说,理解java的多线程是非常容易的事情,但是对于我这样的菜鸟来说,这个实在有点难,可能是我太菜了,网上重复的陈述对于我理解这 ...

  6. IDEA最常用快捷键汇总+快速写出Main函数

    IDEA可以说是当下Java程序员日常开发的神器,但是想要发挥这款神器的牛逼威力,必须得熟练使用它的各种快捷键才行.本篇总结下使用IDEA(也就是IntelliJ IDEA )进行日常开发中最常用的快 ...

  7. Fragment的生命周期(与Activity的对比)

    Fragment必须是依存与Activity而存在的,因此Activity的生命周期会直接影响到Fragment的生命周期.官网这张图很好的说明了两者生命周期的关系: 可以看到Fragment比Act ...

  8. GitHub上优秀的开源项目(转载)

    转载出处:https://github.com/Trinea/android-open-project 第一部分 个性化控件(View) 主要介绍那些不错个性化的 View,包括 ListView.A ...

  9. [译]Nginx入门引导教程

    本文为[Beginner's Guide]译文,原文地址:http://nginx.org/en/docs/beginners_guide.html Guide 本教程基础的介绍了 nginx,以及能 ...

  10. Python--将文件夹中图片按照横屏竖屏进行分类

    搬运链接:https://www.jianshu.com/p/c8be54282e77 """ 可以遍历输入的路径的指定后缀的文件,主要是用来筛选图片,将图片分成 横屏, ...