zoukankan      html  css  js  c++  java
  • hdu1058 Humble Numbers 解题报告

    各种水 题目是简单使用动态规划 使用已有的动态规划进行推导

    先上代码

    1

    2

    3

    5

    7

    1 2

      4

    3

    5

    7

    1 2 3

      4

      6

    5

    7

    最后注意输出 即可

    /*
      Name:
      Copyright:
      Author:yujiaao
      Date:
      Description:hdu
    */
    #include<iostream>
    #include<cstdio>
    using namespace std;
    int list[5845];
    int f_min(int a,int b,int c,int d)
    {
        int m=a<b?a:b;
        int n=c<d?c:d;
        return n<m?n:m;
    }
    int main()
    {
    //    freopen("C:\\Users\\yujiaao\\Desktop\\测试专用\\in.txt","r",stdin);
    //    freopen("C:\\Users\\yujiaao\\Desktop\\测试专用\\out.txt","w",stdout);
        list[0]=1;
        int i2=0,i3=0,i5=0,i7=0;
        int i=0;
        int temp;
        int n;
        for(i=1;i<5843;i++)
        {
            list[i]=f_min(2*list[i2],3*list[i3],5*list[i5],7*list[i7]);
            if(list[i]%2==0)
            i2++;
            if(list[i]%3==0)
            i3++;
            if(list[i]%5==0)
            i5++;
            if(list[i]%7==0)
            i7++;        
        }
        while(scanf("%d",&n)!=EOF &&n!=0)
        {
            if(n%10==1&&n%100!=11)
            printf("The %dst humble number is %d.\n",n,list[n-1]);
            else if(n%10==2&&n%100!=12)
            printf("The %dnd humble number is %d.\n",n,list[n-1]);
            else if(n%10==3&&n%100!=13)
            printf("The %drd humble number is %d.\n",n,list[n-1]);
            else
            printf("The %dth humble number is %d.\n",n,list[n-1]);
        }
        system("pause");
        return 0;
    }
  • 相关阅读:
    可以多个广告浮动的页面
    获取内容并截取长度用...替换
    用UIManager使Swing界面转换风格。
    Java FileInputStream
    win7 部署tomcat总结
    观察者模式
    Java RandomAccessFile
    Java 客户端界面功能:停止当前操作
    多线程的开启与管理
    log4j内容记录
  • 原文地址:https://www.cnblogs.com/yujiaao/p/2652089.html
Copyright © 2011-2022 走看看