题目链接

题意:素因子中只有2 3 5 7的数称为谦逊的数,1也是谦逊的数,题目中已经给出了前20个谦逊的数。给定数字n,按格式输出第n个谦逊的数。

题解:打表即可,注意打表的技巧就行了。

ps:这道题和去年多校做过的一道题很像,那道题是输出大于等于n的第一个数,附上链接:传送门

  1. #include <cstdio>
  2. #include <iostream>
  3. using namespace std;
  4. #define N 6005
  5. typedef long long ll;
  6. ll data[N];
  7. int cnt,n;
  8. void get()
  9. {
  10. cnt=;
  11. data[]=;
  12. int p2=,p3=,p5=,p7=;
  13. for(int i=; i<=; i++)
  14. {
  15. data[i]=min(min(data[p2]*,data[p3]*),min(data[p5]*,data[p7]*));
  16. if(data[i]==data[p2]*) p2++;
  17. if(data[i]==data[p3]*) p3++;
  18. if(data[i]==data[p5]*) p5++;
  19. if(data[i]==data[p7]*) p7++;
  20. }
  21. }
  22. int main()
  23. {
  24. get();
  25. while(scanf("%d",&n)&&n)
  26. {
  27. printf("The %d",n);
  28. if(n%!=&&n%==) printf("st");
  29. else if(n%!=&&n%==) printf("nd");
  30. else if(n%!=&&n%==) printf("rd");
  31. else printf("th");
  32. printf(" humble number is ");
  33. printf("%lld.\n",data[n]);
  34. }
  35. return ;
  36. }

SCU 1029 Humble Numbers (打表处理)的更多相关文章

  1. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  2. HDU - The number of divisors(约数) about Humble Numbers

    Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence ...

  3. A - Humble Numbers

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Pract ...

  4. The number of divisors(约数) about Humble Numbers[HDU1492]

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  5. Humble Numbers

    Humble Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9988 Accepted: 4665 Descri ...

  6. 洛谷P2723 丑数 Humble Numbers

    P2723 丑数 Humble Numbers 52通过 138提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 暂时没有讨论 题目背景 对于一给定的素数 ...

  7. HDU 1058 Humble Numbers (DP)

    Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  8. HDOJ 1058 Humble Numbers(打表过)

    Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...

  9. The number of divisors(约数) about Humble Numbers

    The number of divisors(约数) about Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

随机推荐

  1. C语言宏中"#"和"##"的用法

    转自:https://www.cnblogs.com/hnrainll/archive/2012/08/15/2640558.html 在查看linux内核源码的过程中,遇到了许多宏,这里面有许多都涉 ...

  2. [NOIP2017]宝藏 子集DP

    题面:[NOIP2017]宝藏 题面: 首先我们观察到,如果直接DP,因为每次转移的代价受上一个状态到底选了哪些边的影响,因此无法直接转移. 所以我们考虑分层DP,即每次强制现在加入的点的距离为k(可 ...

  3. hihoCoder#1698 : 假期计划 组合数

    题面:hihoCoder#1698 : 假期计划  组合数 题解: 题目要求是有序的排列,因此我们可以在一开始就乘上A!*B!然后在把这个序列划分成很多段. 这样的话由于乘了阶乘,所以所有排列我们都已 ...

  4. BZOJ4754 & 洛谷4323 & LOJ2072:[JSOI2016]独特的树叶——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4754 https://www.luogu.org/problemnew/show/P4323 ht ...

  5. C++中static用法

    本文为个人学习笔记,参考<C++ Primer(中文第五版)>和<王道程序员求职宝典> 本文分为两个部分:不考虑类.类中static的作用 一.不考虑类,static的作用 1 ...

  6. HDU.1233 还是畅通工程(Prim)

    HDU.1233 还是畅通工程(Prim) 题意分析 首先给出n,代表村庄的个数 然后出n*(n-1)/2个信息,每个信息包括村庄的起点,终点,距离, 要求求出最小生成树的权值之和. 注意村庄的编号从 ...

  7. MySQL5.6之Index Condition Pushdown(ICP,索引条件下推)-Using index condition

    http://blog.itpub.net/22664653/viewspace-1210844/ -- 这篇博客写的更细,以后看 ICP(index condition pushdown)是mysq ...

  8. spring的RestTemplate使用指南

    前言:现在restful接口越来越广泛,而如今很多接口摒弃了传统的配置复杂的webService开发模式,在java领域只需要很简单的springMvc就可以声明为一个控制器,再加上service层, ...

  9. windows下vue项目启动步骤

    原创:https://blog.csdn.net/qq_27680317/article/details/71123051?locationNum=10&fps=1 不是ngnix服务器是,忽 ...

  10. oracle数据库解锁

    当我们修改数据库时用for update 或者使用rowId修改后,对表进行了锁定,由于某种原因没有对他进行关闭,我们需要关闭 select b.username,b.sid,b.serial#,lo ...