hdu 5878 I Count Two Three 丑数 二分
来源:互联网 发布:数据库建库 编辑:程序博客网 时间:2024/05/22 06:26
I Count Two Three
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 649 Accepted Submission(s): 332
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 thei -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 form2a3b5c7d "I Count Two Three Numbers".
A related board game with a given positive integern from one agent, asks all participants the smallest "I Count Two Three Number" no smaller than n .
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
At recent dinner parties, we call the integers with the form
A related board game with a given positive integer
Input
The first line of input contains an integer t (1≤t≤500000) , the number of test cases. t test cases follow. Each test case provides one integer n (1≤n≤109) .
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
1011113123123412345123456123456712345678123456789
Sample Output
11214125125012348123480123480012348000123480000
Source
2016 ACM/ICPC Asia Regional Qingdao Online
不懂得可以搜下丑数的求法。
#pragma comment(linker,"/STACK:124000000,124000000")#include <algorithm>#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <vector>#include <math.h>#include <queue>#include <set>#include <map>#define lson i<<1#define rson i<<1|1#define ll long long#define clr(a,b) memset(a,b,sizeof(a))#define scanfi(a) scanf("%d",&a)#define scanfs(a) scanf("%s",a)#define scanfl(a) scanf("%I64d",&a)#define scanfd(a) scanf("%lf",&a)#define key_val ch[ch[root][1]][0]#define eps 1e-7#define inf 0x3f3f3f3f3f3f3f3fusing namespace std;const int maxn = 10000;int dp[maxn];template<class T> void read(T&num){ char CH; bool F=false; for(CH=getchar(); CH<'0'||CH>'9'; F= CH=='-',CH=getchar()); for(num=0; CH>='0'&&CH<='9'; num=num*10+CH-'0',CH=getchar()); F && (num=-num);}int stk[70], tp;template<class T> inline void print(T p){ if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + '0'); putchar('\n');}int main(){ int T,n; scanf("%d",&T); dp[0] = 1; int d,d2,d3,d5,d7; d = 1; d2 = d3 = d5 = d7 = 0; while(dp[d-1] < 1e9) { int ans; ans = min(dp[d2]*2, dp[d3]*3); ans=min(ans,dp[d7]*7); ans=min(ans,dp[d5]*5); if (ans == dp[d2]*2)++d2; if (ans == dp[d3]*3)++d3; if (ans == dp[d5]*5)++d5; if (ans==dp[d7]*7)++d7; dp[d++] = ans; } while (T--) { scanf("%d",&n); int pos =lower_bound(dp,dp+5194,n)-dp; printf("%d\n",dp[pos]); } return 0;}
0 0
- hdu 5878 I Count Two Three 丑数 二分
- hdu 5878 I Count Two Three 丑数
- HDU 5878 I Count Two Three (dfs+二分)
- hdu 5878 I Count Two Three(二分)
- HDU 5878 I Count Two Three (DFS预处理 + 二分)
- hdu 5878 I Count Two Three【预处理打表+二分】
- 【HDU 5878】I Count Two Three(预处理+二分)
- HDU 5878 I Count Two Three(打表加二分)
- HDU-5878-I Count Two Three-预处理+二分
- hdu 5878 I Count Two Three
- 【30.53%】【hdu 5878】I Count Two Three
- HDU 5878 I Count Two Three .
- HDU 5878 - I Count Two Three
- HDU 5878 I Count Two Three
- HDU-5878-I Count Two Three
- hdu I Count Two Three(二分查找&&打表)
- 2016ICPC网赛青岛站1001 I Count Two Three丑数的应用求解
- HDU 5878-I Count Two Three(可被2 3 5 7整除的数)
- HDU 5898 odd-even number 2016年沈阳网络赛 (数位dp)
- JS-如何使用DOM操纵样式表
- 字典序问题
- 比特同步和帧同步的区别
- 【POJ3393】Lucky and Good Months by Gregorian Calendar
- hdu 5878 I Count Two Three 丑数 二分
- EL表达式
- tp 学习基础
- poj 1011 Sticks
- HDU 2047 - 阿牛的EOF牛肉串(递推)
- [OICamp 2016 Day 1][JZOJ4773]凸包
- C++实现数据结构-队列
- 初识bitset
- hdu5894 hannnnah_j’s Biological Test