• HDOJ(HDU).1058 Humble Numbers (DP)


    HDOJ(HDU).1058 Humble Numbers (DP)

    点我挑战题目

    题意分析

    代码总览

    /*
        Title:HDOJ.1058
        Author:pengwill
        Date:2017-2-15
    */
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cstring>
    #define nmax 6000
    #define min(a,b) (a<b?a:b)
    #define min4(a,b,c,d) min(min(a,b),min(c,d))
    using namespace std;
    int r[nmax];
    int a = 1,b=1,c=1,d=1,len,tail;
    int main()
    {
        r[1] =1;
        for(int i = 2; i<=5842;++i){
            r[i] = min4(2*r[a],3*r[b],5*r[c],7*r[d]);
            if(r[i] == 2*r[a]) a++;
            if(r[i] == 3*r[b]) b++;
            if(r[i] == 5*r[c]) c++;
            if(r[i] == 7*r[d]) d++;
        }
        int t;
        while(scanf("%d",&t) && t ){
             printf("The %d", t);
             if(t%10 == 1 && t%100 != 11) printf("st ");
             else if(t%10 == 2 && t%100 != 12) printf("nd ");
             else if(t%10 == 3 && t%100 != 13) printf("rd ");
             else printf("th ");
             printf("humble number is %d.
    ", r[t]);
    
        }
        return 0;
    }
    
  • 相关阅读:
    Remove Element
    C++ 一些STL
    Two Pointers/hash/3Sum/4Sum类题目
    动态规划
    UVa 12657 双向链表
    并行运行环境
    多线程编程
    HTML XML CSS JS 迅速学习
    UVa 11988 数组模拟链表
    静态链表
  • 原文地址:https://www.cnblogs.com/pengwill/p/7367162.html
Copyright © 2020-2023  润新知