zoukankan      html  css  js  c++  java
  • 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
    ", a[ans]);
    32     }
    33 
    34     return 0;
    35 }
     
  • 相关阅读:
    html_Dom
    html_javascript
    html_之css
    协程
    进程和线程的总结
    html_基础标签
    html_头部<meta>设置
    Python_queue单项队列
    Python_paramiko模块
    Python_多进程multiprocessing
  • 原文地址:https://www.cnblogs.com/cshg/p/5889989.html
Copyright © 2011-2022 走看看