hdu 1058 Humble Number

Humble Number

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1058

解题思路:

orz英语序数。。。

first 第一   second 第二   third 第三   fourth 第四   fifth 第五   sixth 第六   seventh 第七   eighth 第八   ninth 第九   tenth 第十   eleventh 第十一   twelfth 第十二   thirteenth 第十三   fourteenth 第十四   fifteenth 第十五   sixteenth 第十六   seventeenth 第十七   eighteenth 第十八   nineteenth 第十九   twentieth 第二十   twenty-first 第二十一   twenty-second 第二十二   twenty-third 第二十三   

剩下的直接求丑数就行了。。。

AC代码:

#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll,int> node_type;
ll result[6000];

int main(){
    priority_queue<node_type,vector<node_type>,greater<node_type> > q;
    q.push(make_pair(1,2));
    for(int i = 1; i <= 5842; i++){
        node_type node  = q.top();
        q.pop();
        switch(node.second){
        case 2: q.push(make_pair(node.first*2,2));
        case 3: q.push(make_pair(node.first*3,3));
        case 5: q.push(make_pair(node.first*5,5));
        case 7: q.push(make_pair(node.first*7,7));
        }
        result[i] = node.first;
    }
    int n;
    while(scanf("%d",&n) && n){
        int tmp = n%10;
        if(tmp == 1 && (n % 100 != 11))
            printf("The %dst humble number is ",n);
        else if(tmp == 2 && (n % 100 != 12))
            printf("The %dnd humble number is ",n);
        else if(tmp == 3 && (n % 100 != 13))
            printf("The %drd humble number is ",n);
        else
            printf("The %dth humble number is ",n);
        printf("%lld.\n",result[n]);//手残,wrong到哭,原因是没有加句号。。。
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值