zoukankan      html  css  js  c++  java
  • 2016 ACM/ICPC Asia Regional Qingdao Online 1001/HDU5878 打表二分

    I Count Two Three

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


    Problem Description
    I will show you the most popular board game in the Shanghai Ingress Resistance Team.
    It all started several months ago.
    We 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 failed.

    After the event, we analysed the laws of failed attacks.
    It's interesting that the i-th attacks failed if and only if i can be rewritten as the form of 2a3b5c7d which a,b,c,d are non-negative integers.

    At recent dinner parties, we call the integers with the form 2a3b5c7d "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. t test cases follow. Each test case provides one integer n (1n109).
     
    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
     
    题意: t组数据 给你一个n  输出不小于n的最短的数x
    x=2^a*3^b*5^c*7^d
    题解:因为最大为1e9  先打表找到所有的满足条件的数x 之后二分答案
     1 /******************************
     2 code by drizzle
     3 blog: www.cnblogs.com/hsd-/
     4 ^ ^    ^ ^
     5  O      O
     6 ******************************/
     7 #include<bits/stdc++.h>
     8 #include<iostream>
     9 #include<cstring>
    10 #include<cmath>
    11 #include<cstdio>
    12 #define ll long long
    13 #define mod 1000000007
    14 #define PI acos(-1.0)
    15 #define N 1000000000
    16 using namespace std;
    17 int t;
    18 ll a2[35]={1},a3[35]={1},a5[35]={1},a7[35]={1};
    19 int jishu;
    20 ll ans[50005];
    21 void init()
    22 {
    23     jishu=0;
    24     int er=0,san=0,wu=0,qi=0;
    25     for(int i=1; a2[i-1]<=N;er++,i++)
    26         a2[i]=a2[i-1]*2;
    27     for(int i=1; a3[i-1]<=N;san++,i++)
    28         a3[i]=a3[i-1]*3;
    29     for(int i=1; a5[i-1]<=N;wu++,i++)
    30         a5[i]=a5[i-1]*5;
    31     for(int i=1; a7[i-1]<=N;qi++, i++)
    32         a7[i]=a7[i-1]*7;
    33     for(int i=0; i<er; i++)
    34         for(int j=0; a2[i]*a3[j]<=N&&j<san; j++)
    35             for(int k=0; a2[i]*a3[j]*a5[k]<=N&&k<wu; k++)
    36                 for(int l=0; a2[i]*a3[j]*a5[k]*a7[l]<=N&&l<qi; l++)
    37                     ans[jishu++]=a2[i]*a3[j]*a5[k]*a7[l];
    38     sort(ans,ans+jishu);
    39 }
    40 int main()
    41 {
    42     int n;
    43     while(scanf("%d",&t)!=EOF)
    44     {
    45         init();
    46         for(int i=1; i<=t; i++)
    47         {
    48             scanf("%d",&n);
    49             printf("%I64d
    ",ans[lower_bound(ans,ans+jishu,n)-ans]);
    50         }
    51     }
    52     return 0;
    53 }
     
  • 相关阅读:
    python接口自动化之发送post(四)
    python接口自动化之发送get(三)
    python接口自动化之fiddler使用(二)
    python读取yaml配置文件
    python接口自动化测试之http协议(一)
    python接口自动化测试之根据excel中的期望结果是否存在于请求返回的响应值中来判断用例是否执行成功
    python3读取、写入、追加写入excel文件
    python UI自动化之处理多窗口
    python UI自动化之js操作
    python UI自动化之切换iframe
  • 原文地址:https://www.cnblogs.com/hsd-/p/5894131.html
Copyright © 2011-2022 走看看