2016 ACM/ICPC Asia Regional Qingdao Online HDU5878

Posted 樱花落舞

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2016 ACM/ICPC Asia Regional Qingdao Online HDU5878相关的知识,希望对你有一定的参考价值。

链接:http://acm.hdu.edu.cn/showproblem.php?pid=5878

解法:先保存,再二分查询~具体http://blog.csdn.net/coder_xia/article/details/6707600

#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define MAXN (100000+10)
#define MAXM (100000)
#define inf 0x3fffffff
#define INF 0x3f3f3f3f
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define ULL unsigned long long
using namespace std;
long long data[10000];
long long index = 0;
void get(int n)
{
    data[0] = 1;
    long long T2 = 0;
    long long T3 = 0;
    long long T5 = 0;
    long long T7 = 0;
   // long long index = 0;
    while (index < n)
    {
        index++;
        long long d1=min(data[T2] * 2, data[T3] * 3);
        long long d2=min(data[T5] * 5, data[T7] * 7);
        long long d = min(d1,d2);
        data[index] = d;
        while (data[T2] * 2 == data[index]) T2++;
        while (data[T3] * 3 == data[index]) T3++;
        while (data[T5] * 5 == data[index]) T5++;
        while (data[T7] * 7 == data[index]) T7++;
    }
}
int main()
{
    int i,n;
    get(7000);
   // cout<<data[7000]<<endl;
 //  cout<<index<<endl;
    int t;
    while(~scanf("%d",&t))
    {
    }
    while(t--)
    {
        int m;
        scanf("%d",&m);
        int pos=lower_bound(data,data+index,m)-data;
        printf("%lld\n",data[pos]);
    }
    return 0;
}

  

以上是关于2016 ACM/ICPC Asia Regional Qingdao Online HDU5878的主要内容,如果未能解决你的问题,请参考以下文章

2016 ACM/ICPC Asia Regional Shenyang Online

2016 ACM/ICPC Asia Regional Qingdao Online HDU5889

2016 ACM/ICPC Asia Regional Qingdao Online 1002 Cure

2016 ACM/ICPC Asia Regional Qingdao Online

2016 ACM/ICPC Asia Regional Qingdao Online HDU5883

2016 ACM/ICPC Asia Regional Shenyang Online