HDU5878-I Count Two Three
来源:互联网 发布:名片设计app软件 编辑:程序博客网 时间:2024/05/22 17:19
I Count Two Three
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 688 Accepted Submission(s): 360
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
题意:找到由2a3b5c7d组成的第一个大于等于n的值
分析:由2a3b5c7d 组成的值很少,只有几千,预处理打表,然后用二分查找
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <set>using namespace std;#define ll long longll a[10005];ll mypow(ll a,ll b){ ll ans=1; while(b) { if(b&1) ans=(ans*a); b>>=1; a=a*a; } return ans;}int main(){ int t,x,f1,f2,f3; int cnt=0; for(int i=0; i<30; i++) { f1=0; for(int j=0; j<30; j++) { f2=0; for(int k=0; k<30; k++) { f3=0; for(int l=0; l<30; l++) { ll sum=1; sum*=mypow(2,i); if(sum>1e9) { f1=1; break; } sum*=mypow(3,j); if(sum>1e9) { f2=1; break; } sum*=mypow(5,k); if(sum>1e9) { f3=1; break; } sum*=mypow(7,l); if(sum>1e9) { break; } a[cnt++]=sum; } if(f3==1) break; } if(f2==1) break; } if(f1==1) break; } sort(a,a+cnt); scanf("%d",&t); while(t--) { scanf("%d",&x); int p=lower_bound(a,a+cnt,x)-a; printf("%lld\n",a[p]); } return 0;}
0 0
- HDU5878-I Count Two Three
- hdu5878 I Count Two Three(水题)
- 青岛网赛1001 HDU5878 I Count Two Three
- hdu5878 I Count Two Three -ICPC网络赛青岛赛区
- 【HDU5878】I Count Two Three(打表+二分)
- 暴力求解法--打表 hdu5878 I count Two Three
- HDU5878——I Count Two Three(2016年青岛区域赛网络赛)
- HDU5878 I Count Two Three【打表+排序+二分搜索】
- I Count Two Three
- 5878 I Count Two Three
- hdoj-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
- hdoj 5878 I Count Two Three
- HDU-5878-I Count Two Three
- 用户id加密
- 全栈必备Linux 基础
- linux(x64)下安装Matlab 2015b破解版(含安装包)
- SQL logic error or missing database no such table: xxx
- sqlite中的锁及概念误区
- HDU5878-I Count Two Three
- jstl标签中的循环 s:bean
- 第十五章 课后作业4题
- Java加密算法---HMAC
- IEC61850笔记--IEC61850应用入门(二)
- 配置获取隐私数据权限声明
- 利用java简单调用kafka
- android中shape详解
- Hive总结(十)Hive 输入输出适配类(输出CSV,XML)