• hdu---------3189-------------------


    水体一个,但是这种做题的方法值得发扬光大............

    Just Do It
    
    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 1122    Accepted Submission(s): 743
    
    
    Problem Description
    Now we define a function F(x), which means the factors of x. In particular, F(1) = 1,since 1 only has 1 factor 1, F(9) = 3, since 9 has 3 factors 1, 3, 9. Now give you an integer k, please find out the minimum number x that makes F(x) = k.
     
    
    Input
    The first line contains an integer t means the number of test cases.
    The follows t lines, each line contains an integer k. (0 < k <= 100).
     
    
    Output
    For each case, output the minimum number x in one line. If x is larger than 1000, just output -1.
     
    
    Sample Input
    4
    4
    2
    5
    92
     
    
    Sample Output
    6
    2
    16
    -1

    意思大概是,,,,,,9的因子都有1  3  9   三个数字  4也有三个因子    现在输入一个3  你需要输出   4(因为4 是有三个因子的数字中最小的数字)....意思就是这            很简单打表遍历,,,,但是  遍历的时候想到了,,,  如果倒序   遍历的话,例如  便利到9发现有3个因子,

    这时候数组赋值为   a[3]=9;   然后一会有到4了,也是4个因子  在此进行赋值  a[3]=4;   这样的话,,简单又弱智

    #include<stdio.h>
    #include<string.h>
    int main()
    {
        int q,i,j,m,n,t,a[1001],b,c;
        memset(a,0,sizeof(a));
        for(i=1000;i>0;i--)
        {
            q=0;
            for(j=i;j>0;j--)
            {
                if(i%j==0)
                    q++;
            }
            a[q]=i;
        }
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d",&n);
            m=a[n];
            if(m==0)
                m=-1;
            printf("%d
    ",m);
        }
        return 0;
    }
  • 相关阅读:
    PgSQL定时备份
    如何从源码包安装软件?
    PostgreSQL PointInTime Recovery (Incremental Backup)
    Better PostgreSQL backups with WAL archiving
    安装GTK全攻略
    WEB前端开发规范文档
    Linux开机自动启动脚本方法
    安装编译postgresql与pgagent的相关操作
    PostgreSQL: 如何查询表的创建时间?
    什么是编程
  • 原文地址:https://www.cnblogs.com/A-FM/p/5125244.html
Copyright © 2020-2023  润新知