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
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 i-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 form 2a3b5c7d "I Count Two Three Numbers".
A related board game with a given positive integer n from one agent, asks all participants the smallest "I Count Two Three Number" no smaller than n.
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
using namespace std;
int t,x,len;
int arr[];
int main()
{
len=;
for(int a=;a<=;a++)
{
double aa=pow(2.0,a*1.0);
for(int b=;b<=;b++)
{
double bb=pow(3.0,b*1.0);
if (aa*bb>=1200000000.0) break;
for(int c=;c<=;c++)
{
double cc=pow(5.0,c*1.0);
if (aa*bb*cc>=1200000000.0) break;
for(int d=;d<=;d++)
{
double dd=pow(7.0,d*1.0);
if (aa*bb*cc*dd>=1200000000.0) break;
arr[++len]=(int)aa*bb*cc*dd;
}
}
}
}
sort(arr+,arr+len+);
//printf("%d\n",arr[len]);
//for(int i=1;i<=len;i++) printf("%d ",arr[i]);
// printf("%d\n",len);
while(scanf("%d",&t)!=EOF)
{
for(;t>;t--)
{
scanf("%d",&x); // set<int> s;
// s.insert(1);
// while(!s.empty())
// {
// set<int>::iterator ii;
// ii=s.begin();
// if (*ii>=x) {printf("%d\n",*ii); break;}
// s.erase(s.begin());
// int k=*ii;
// if(k*2<1200000000) s.insert(k*2);
// if(k*3<1200000000) s.insert(k*3);
// if(k*5<1200000000) s.insert(k*5);
// if(k*7<1200000000) s.insert(k*7);
// } int l=,r=len;
while(l<r)
{
int mid=(l+r)/;
if (arr[mid]<x) l=mid+;
else r=mid;
}
printf("%d\n",arr[l]); }
}
return ;
}
2016 ACM/ICPC Asia Regional Qingdao Online 1001 I Count Two Three的更多相关文章
- 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( ...
- 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 ...
- 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^ ...
- 数学--数论--HDU--5878 Count Two Three 2016 ACM/ICPC Asia Regional Qingdao Online 1001
I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...
- 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 S ...
- 2016 ACM/ICPC Asia Regional Qingdao Online(2016ACM青岛网络赛部分题解)
2016 ACM/ICPC Asia Regional Qingdao Online(部分题解) 5878---I Count Two Three http://acm.hdu.edu.cn/show ...
- 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 ...
- 2016 ACM/ICPC Asia Regional Qingdao Online
吐槽: 群O的不是很舒服 不知道自己应该干嘛 怎样才能在团队中充分发挥自己价值 一点都不想写题 理想中的情况是想题丢给别人写 但明显滞后 一道题拖沓很久 中途出岔子又返回来搞 最放心的是微软微软妹可以 ...
- 【2016 ACM/ICPC Asia Regional Qingdao Online】
[ HDU 5878 ] I Count Two Three 考虑极端,1e9就是2的30次方,3的17次方,5的12次方,7的10次方. 而且,不超过1e9的乘积不过5000多个,于是预处理出来,然 ...
随机推荐
- bash元字符(上)
元字符 行动 样例 回车换行 结束一个命令 空格 切割命令行中的元素 ls /etc Tab 命令自己主动补全 # 開始一行凝视 #This is a comment line " 引用多个 ...
- 读书笔记—CLR via C#异常和状态管理
前言 这本书这几年零零散散读过两三遍了,作为经典书籍,应该重复读反复读,既然我现在开始写博了,我也准备把以前觉得经典的好书重读细读一遍,并且将笔记整理到博客中,好记性不如烂笔头,同时也在写的过程中也可 ...
- Js Date泣血整理
原文:Js Date泣血整理 JS Date 对象用于处理日期和时间. 创建 Date 对象的语法: var myDate=new Date() Date 对象会自动把当前日期和时间保存为其初始值. ...
- SQL Server 2008 允许远程链接,适用于广域网和局域网
用户在使用SQL Server 2008远程链接时,可能会弹出如下对话框: 在链接SQL服务器时发生网络链接错误或特定实例错误.SQL服务器不存在或者链接不成功.请验证用户名是否正确或SQL服务器是否 ...
- .NET MVC4 实训记录之一(引入Unity3.0 Ioc框架)
一直在做维护项目,没有机会接触完整的架构,于是自学.NET MVC.自今日起,将自学的过程.遇到的问题以及解决方案记录下来. 在WebApp项目中右键,使用NuGet引入Unity3.0.
- 单点登录(SSO)实现方式
谁都能看懂的单点登录(SSO)实现方式(附源码) SSO的基本概念 SSO英文全称Single Sign On(单点登录).SSO是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用 ...
- 如何解决 Django中出现的 [Errno 13] Permission denied问题
环境:linux 如果你使用了Apache部署了Django项目,在上传文件时可能会出现 “[Errno 13] Permission denied:某目录”的错误. 这是因为apache没有权限在该 ...
- Day2:T3DP(基于排列组合思想)
T3:DP(基于排列组合思想的状态转移) 其实之前写排列组合的题目有一种很茫然的感觉.... 应该是因为之前没有刷过所以没有什么体会 上次刷的vj1060有用到,但是写状态转移还是第一次学习吧 ccy ...
- 关于grub的那些事(一)
/etc/default/grub里的秘密: # If you change this file, run 'update-grub' afterwards to update # /boot/gru ...
- 如何理解signal函数声明
Signal函数用起来其实很简单,但是回头看看他的声明,相信会有很多人表示费解.自己也在这个问题中纠结了好几年了,今天终于弄明白,很是兴奋,一起分享一下. 先看函数原型:void (*signal(i ...