【hdu 1058】Humble Numbers

来源:互联网 发布:剑三成女脸型数据下载 编辑:程序博客网 时间:2024/05/24 23:11

只想说一句,只是在考英语吗?

#include<cstdio>#include<cstring>#include<iostream>#include<queue>#define LL long longusing namespace std;int n,cnt;LL f[5865];LL cur[]={0,2,3,5,7};priority_queue<LL,vector<LL>,greater<LL> >q;void solve(){int last=0;q.push(1);while(cnt<5842){if(q.top() == last){q.pop() ;continue;}f[++cnt]=q.top();q.pop();for(int i=1;i<=4;i++)q.push(cur[i]*f[cnt]);last=f[cnt];}}int main(){solve();while(scanf("%d",&n)&&n){if(n%10==1&&n%100!=11)printf("The %dst humble number is %d.\n",n,f[n]);else if(n%10==2&&n%100!=12)printf("The %dnd humble number is %d.\n",n,f[n]);else if(n%10==3&&n%100!=13)printf("The %drd humble number is %d.\n",n,f[n]);else  printf("The %dth humble number is %d.\n",n,f[n]);}return 0;}


0 0
原创粉丝点击