poj 2247

1 注意数的大小

2 注意输出时111,112这些数字

#include<iostream>
#include<fstream>
#include<algorithm>
#define M 2000000000
using namespace std;
int a[6000];
int main(){
    int len=0;
  long long num2=1,num3=1,num5=1,num7=1;
    while(num2<=M){
        while(num2*num3<=M){
            while(num2*num3*num5<=M){
                while(num2*num3*num5*num7<=M){
                    a[len++]=num2*num3*num5*num7;
                    num7*=7;
                }
                num5*=5;
                num7=1;
            }
            num3*=3;
            num5=1;
        }
        num2*=2;
        num3=1;
    }
    sort(a,a+len);
    int n;
    //fstream cin("1.txt");
    while(cin>>n&&n!=0){
        if(n%10==1){
            if(n%100==11){
                cout<<"The "<<n<<"th humble number is "<<a[n-1]<<"."<<endl;
            }else{
                cout<<"The "<<n<<"st humble number is "<<a[n-1]<<"."<<endl;
            }
        }else if(n%10==2){
            if(n%100==12){
                cout<<"The "<<n<<"th humble number is "<<a[n-1]<<"."<<endl;
            }else{
                cout<<"The "<<n<<"nd humble number is "<<a[n-1]<<"."<<endl;
            }
        }else if(n%10==3){
            if(n%100==13){
                cout<<"The "<<n<<"th humble number is "<<a[n-1]<<"."<<endl;
            }else{
                cout<<"The "<<n<<"rd humble number is "<<a[n-1]<<"."<<endl;
            }
        }else{
            cout<<"The "<<n<<"th humble number is "<<a[n-1]<<"."<<endl;
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值