• hdu 5878 I Count Two Three


    I Count Two Three

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 719    Accepted Submission(s): 380


    Problem DesI will show you the most popular board game in the Shanghai Ingress Resistance TeIt all started several months agoWe found out the home address of the enlightened agent Icount2three and decided to draw him out.Millions of missiles were detonated, but some of them failedAfter the event, we analysed the laws of failed attacks.
    It's interesting that the i -th attacks failed if and only if can be rewritten as the form of 2^a*3^b*5^c*7^dwhich a,b,c,d are non-negative integers.

    At recent dinner parties, we call the integers with the form2^a*3^b*5^c*7^d "I Count Two Three Numbers".
    A related board game with a given positive integer n from one agent, asks all participants the smallest "I Count Two Three Number" no smaller than n .
     
    Input
    The first line of input contains an integer t (1t500000), the number of test cases. test cases follow. Each test case provides one integer n (1n10^9) .
     
    Output
    For each test case, output one line with only one integer corresponding to the shortest "I Count Two Three Number" no smaller than n .
     
    Sample Input
    10
    1
    11
    13
    123
    1234
    12345
    123456
    1234567
    12345678
    123456789
     
    Sample Output
    1
    12
    14
    125
    1250
    12348
    123480
    1234800
    12348000
    123480000
     
    Source
     
    题意:对于每一个输入的N,找一个不小于N的最小的满足条件的值(使得这个值的因子是2,3,5,7)
    思路:暴力,之后二分搜索来查找。
    AC代码:
    #define _CRT_SECURE_NO_DEPRECATE
    #include<iostream>
    #include<algorithm>
    using namespace std;
    const int maxn = 1000000000 + 5;
    const int N_MAX =5200;
    typedef long long LL;
    //LL table[10000];
    LL a[N_MAX] = {0,1,2,3,4,5,6,7,8,9,10};
    LL p[4] = { 2,3,5,7 };
    int main() {
        int T,n;
        for (int i = 10;i < N_MAX;i++) {
            a[i] = INT_MAX;
            int k = i - 1;
            for (int j = 0;j < 4;j++) {
                while (a[k-1] * p[j]>a[i - 1])
                    k--;
                a[i] = min(a[i],a[k]*p[j]);
            }
        }
        /*int cnt = 0;
        for (LL a =1;a <maxn;a*=2) {
            for (LL b=1;a*b <maxn;b*=3) {
                for (LL c = 1;a*b*c < maxn;c *= 5) {
                    for (LL d = 1;a*b*c*d < maxn;d *= 7) {
                        table[cnt++] = a*b*c*d;
                    }
                }
            }
        }
        sort(table, table + cnt);*/
        scanf("%d",&T);
        while (T--) {
            scanf("%d",&n);
            int id=*lower_bound(a+1, a +N_MAX,n);
            printf("%d
    ", id);
        }
        
        return 0;
    }
  • 相关阅读:
    [实变函数]4.4 依测度收敛
    [实变函数]4.3 可测函数的构造
    [实变函数]4.2 Egrov 定理
    [实变函数]4.1 可测函数 (measurable function) 及其性质
    [实变函数]4.0 引言
    [实变函数]3.3 可测集类
    垂直滚动选择效果的实现
    unity模型任意无限切割插件
    微信小程序—智能小蜜(基于智能语义解析olami开放平台)
    AdPlayBanner:功能丰富、一键式使用的图片轮播插件
  • 原文地址:https://www.cnblogs.com/ZefengYao/p/5890972.html
Copyright © 2020-2023  润新知