hdu 5878 I Count Two Three 2016ACM/ICPC青岛赛区网络赛1001
来源:互联网 发布:安装ubuntu分区顺序 编辑:程序博客网 时间:2024/05/16 05:45
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
暴力预处理出所有的10^9以内只有2,3,5,7因子的数
然后直接二分查找即可
#include<map>#include<cmath>#include<queue>#include<vector>#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<algorithm>using namespace std;long long a[10000001];inline long long findx(int l,int r,long long x){while(l<=r){int mid=(l+r)/2;if(a[mid]<x)l=mid+1;elser=mid-1;}return a[l];}int main(){int i,j,k,l;long long ii=1,jj,kk,ll; int tot=0;for(i=0;i<=32;i++){long long ans=ii;jj=1;for(j=0;j<=19;j++){ans*=jj;if(ans>1000000000){ans/=jj;break;}kk=1;for(k=0;k<=13;k++){ans*=kk;if(ans>1000000000){ans/=kk;break;}ll=1;for(l=0;l<=11;l++){ans*=ll;if(ans>1000000000){ans/=ll;break;}tot++;a[tot]=ans;ans/=ll;ll*=7LL;}ans/=kk;kk*=5LL;}ans/=jj;jj*=3LL;}ans/=ii;ii*=2LL;}sort(a+1,a+1+tot);int T;scanf("%d",&T);while(T>0){T--;int n;scanf("%d",&n);printf("%I64d\n",findx(1,tot,n));}return 0;}
0 0
- hdu 5878 I Count Two Three 2016ACM/ICPC青岛赛区网络赛1001
- 2016 ACM/ICPC 青岛赛区网络赛 I Count Two Three
- hdu5878 I Count Two Three -ICPC网络赛青岛赛区
- 2016 ACM/ICPC 青岛区域赛网络赛 1001 I Count Two Three(打表+二分)
- hdu 5878 I Count Two Three ICPC青岛站网络赛1001
- HDU 5878 I Count Two Three 青岛网络赛
- HDU 5878 I Count Two Three 2016青岛网赛
- HDU 5878 I Count Two Three(2016亚洲区青岛站网络赛)
- HDU 5878 I Count Two Three 2016 ACM/ICPC Asia Regional Qingdao Online 1001
- HDU 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001)
- 2016ICPC网赛青岛站1001 I Count Two Three丑数的应用求解
- hdu--5878(hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001))
- HDU 5878 I Count Two Three (暴力) 2016 ACM/ICPC Asia Regional Qingdao Online
- 2016ICPC青岛赛区网络赛 1001
- 青岛网赛1001 HDU5878 I Count Two Three
- 2016 ACM/ICPC 青岛赛区网络赛 XM Reserves
- hdu 5879 Cure 2016ACM/ICPC青岛赛区网络赛1002
- hdu 5881 Tea 2016ACM/ICPC青岛赛区网络赛1004
- Spring Batch批处理框架初探
- 面向对象
- Unity资源热更之AssetBundle(2)———旧版本AssetBundle
- MacBook Air 13.3系统恢复及Windows 10安装心得
- 学习整理——Java序列化
- hdu 5878 I Count Two Three 2016ACM/ICPC青岛赛区网络赛1001
- hdu 5879 Cure 2016ACM/ICPC青岛赛区网络赛1002
- UE4修改源码对项目进行加密
- 自学计算机基础
- hdu 5881 Tea 2016ACM/ICPC青岛赛区网络赛1004
- hdu5878 I Count Two Three(水题)
- 抽象类
- 快速排序怎么写?
- [HDU 5886] Tower Defence (树形DP)