hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001)

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

题目大意:

  给出一个数n ,求一个数X, X>=n. X 满足一个条件 X= 2^a*3^b*5^c*7^d 求靠近n的X值。

解题思路:

  打表+二分查找

【切记用 cin cout,都是泪。。。】

AC Code:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 long long na[100002];
 4
 5 int main()
 6 {
 7     int s=0;
 8     long long ans,n,x;
 9     for(int i=0; i<=31; i++)
10         for(int j=0; j<=19; j++)
11             for(int k=0; k<=12; k++)
12                 for(int z=0; z<=11; z++)
13                     if( (ans=pow(2,i)*pow(3,j)*pow(5,k)*pow(7,z))>=1e9+1 )break;
14                     else na[s++]=ans;
15     sort(na,na+s);
16     while(~scanf("%lld",&n))
17     {
18         while(n--)
19         {
20             scanf("%lld",&x);
21             printf("%lld\n",*lower_bound(na,na+s,x));
22         }
23     }
24     return 0;
25 }
时间: 2024-10-01 03:24:05

hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001)的相关文章

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 Resis

2016 ACM/ICPC Asia Regional Qingdao Online 1001 I Count Two Three

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description I will show you the most popular board game in the Shanghai Ingress Resistance Team.It all star

HDU 5889 Barricade 【BFS+最小割 网络流】(2016 ACM/ICPC Asia Regional Qingdao Online)

Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 997    Accepted Submission(s): 306 Problem Description The empire is under attack again. The general of empire is planning to defend his

HDU 5785 Function 【倍增】 (2016 ACM/ICPC Asia Regional Dalian Online)

Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 976    Accepted Submission(s): 375 Problem Description The shorter, the simpler. With this problem, you should be convinced of this tru

hdu 5868 2016 ACM/ICPC Asia Regional Dalian Online 1001 (burnside引理 polya定理)

Different Circle Permutation Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 208    Accepted Submission(s): 101 Problem Description You may not know this but it's a fact that Xinghai Square is

【2016 ACM/ICPC Asia Regional Qingdao Online】

[ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方. 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然后每次二分找就可以了. /* TASK:I Count Two Three 2^a*3^b*5^c*7^d的最小的大于等于n的数是多少 LANG:C++ URL:http://acm.hdu.edu.cn/showproblem.php?pid=5878 */ #include <iostream>

2016 ACM/ICPC Asia Regional Qingdao Online1001 &amp;&amp;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 voi

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> #inclu

2016 ACM/ICPC Asia Regional Qingdao Online HDU5883

链接:http://acm.hdu.edu.cn/showproblem.php?pid=5883 解法:先判断是不是欧拉路,然后枚举 #pragma comment(linker, "/STACK:102400000,102400000") #include <math.h> #include <time.h> #include <stdio.h> #include <string.h> #include <stdlib.h>