• poj2247


    同1338

    View Code
    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    using namespace std;
    
    #define maxn 6000
    #define inf 0x3f3f3f3f
    
    long long f[maxn];
    int pos[4], fac[4];
    
    char* make(int a, char *st)
    {
        if (a % 10 == 1 && a % 100 != 11)
            strcpy(st, "st");
        else if (a % 10 == 2 && a % 100 != 12)
            strcpy(st, "nd");
        else if (a % 10 == 3 && a % 100 != 13)
            strcpy(st, "rd");
        else
            strcpy(st, "th");
        return st;
    }
    
    int main()
    {
    //    freopen("t.txt", "r", stdin);
        f[1] = 1;
        pos[0] = pos[1] = pos[2] = pos[3] = 1;
        fac[0] = 2;
        fac[1] = 3;
        fac[2] = 5;
        fac[3] = 7;
        for (int i = 2; i <= 5842; i++)
        {
            f[i] = -1;
            for (int j = 0; j < 4; j++)
                if (f[pos[j]] * fac[j] < f[i] || f[i] == -1)
                    f[i] = f[pos[j]] * fac[j];
            for (int j = 0; j < 4; j++)
                if (f[pos[j]] * fac[j] <= f[i])
                    pos[j]++;
        }
        int n;
        char st[3];
        while (scanf("%d", &n), n)
            printf("The %d%s humble number is %lld.\n", n, make(n, st), f[n]);
        return 0;
    }
  • 相关阅读:
    Code review
    一点心得
    有关双向追踪性的一点感觉
    测试用例分析的一点心得
    js简单的抽屉菜单
    新的感受
    linux的VPS如何分区
    PHP中Unicode转码和解码的实现
    xampp安装及配置
    js Unicode编码转换
  • 原文地址:https://www.cnblogs.com/rainydays/p/2858056.html
Copyright © 2020-2023  润新知