zoukankan      html  css  js  c++  java
  • poj 2247

    枚举,貌似数据量挺大的,其实不大,就看最深层的tot加了多少次,就可估计出真正的规模

    //枚举
    #include <iostream>
    #include <stdio.h>
    #include <algorithm>
    #define ll long long
    using namespace std;
    const int maxn=2000000000;
    int num[10000];
    int main()
    {	
    	ll i1,i2,i3,i4;//注意long long 因为虽然按理说是不会爆int,相乘这个过程可能会溢出
    	int tot=0;
    	for(i1=1;i1<=maxn;i1*=2)
    	{
    		for(i2=1;i1*i2<=maxn;i2*=3)
    		{
    			for(i3=1;i1*i2*i3<=maxn;i3*=5)
    			{
    				for(i4=1;i1*i2*i3*i4<=maxn;i4*=7)
    					num[tot++]=i1*i2*i3*i4;
    			}
    		}
    	}
    	sort(num,num+tot);
    	int n;
    	while(scanf("%d",&n)&&n)
    	{
    		if(n%100==11) printf("The %dth humble number is %d.\n",n,num[n-1]);
    		else if(n%100==12) printf("The %dth humble number is %d.\n",n,num[n-1]);
    		else if(n%100==13) printf("The %dth humble number is %d.\n",n,num[n-1]);
    		else if(n%10==1) printf("The %dst humble number is %d.\n",n,num[n-1]);
    		else if(n%10==2) printf("The %dnd humble number is %d.\n",n,num[n-1]);
    		else if(n%10==3) printf("The %drd humble number is %d.\n",n,num[n-1]);
    		else printf("The %dth humble number is %d.\n",n,num[n-1]);
    	}
    	return 0;
    }
    


  • 相关阅读:
    (转)Maven实战(三)Eclipse构建Maven项目
    刷欢乐豆的方法
    R-pie()
    R-plot()
    10只老鼠与1000瓶药水
    资源共享
    第一只python小爬虫
    正则表达式之python实现
    马踏棋盘之贪心算法优化
    八皇后之回溯法解决
  • 原文地址:https://www.cnblogs.com/lj030/p/3002275.html
Copyright © 2011-2022 走看看