2016 ACM/ICPC Asia Regional Qingdao Online1001 &&hdoj 5878 I Count Two Three

Posted

tags:

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

题目链接

打表二分。。后来发现这是51nod中的一个原题

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <algorithm>
 4 using namespace std;
 5 typedef long long int ll;
 6 const ll INF = 1e9 + 100000;
 7 ll a[100005];
 8 int cnt = 0;
 9 int x[] = {2,3,5, 7};
10 void dfs(int pos, ll num){
11     if(pos ==  4) {
12         a[cnt++] = num;
13         return;
14     }
15     dfs(pos+1, num);
16     for(int i = 1; i <= 32; i++){
17         if(num*x[pos]> INF) break;
18         dfs(pos+1, num *= x[pos]);
19     }
20 }
21 int main()
22 {
23     dfs(0,1);
24     sort(a, a+cnt);
25     int t;
26     scanf("%d", &t);
27     while(t--){
28         ll y;
29         scanf("%I64d", &y);
30         int ans = lower_bound(a, a+cnt, y) - a;
31         printf("%I64d\n", a[ans]);
32     }
33 
34     return 0;
35 }

 

 

以上是关于2016 ACM/ICPC Asia Regional Qingdao Online1001 &&hdoj 5878 I Count Two Three的主要内容,如果未能解决你的问题,请参考以下文章

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