HDU 5878 I Count Two Three
I Count Two Three
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 767 Accepted Submission(s): 403
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 <cstdio>
#include <algorithm>
#define ll long long
using namespace std; ll a[10000]; void get(int n)
{
a[0] = 1;
int n2 = 0;
int n3 = 0;
int n5 = 0;
int n7 = 0;
int cnt = 1;
while(cnt < n){
ll t1 = min(a[n2]*2, a[n3]*3);
ll t2 = min(a[n5]*5, a[n7]*7);
ll t = min(t1, t2);
if(t == a[n2]*2)
++n2;
if(t == a[n3]*3)
++n3;
if(t == a[n5]*5)
++n5;
if(t == a[n7]*7)
++n7;
a[cnt++] = t;
}
} int main()
{
get(5200);
int t, n;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
printf("%I64d\n", *lower_bound(a, a+5219, n));
}
return 0;
}
HDU 5878 I Count Two Three的更多相关文章
- 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 I Count Two Three(二分)
I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all started ...
- HDU 5878 I Count Two Three (打表+二分查找) -2016 ICPC 青岛赛区网络赛
题目链接 题意:给定一个数n,求大于n的第一个只包含2357四个因子的数(但是不能不包含其中任意一种),求这个数. 题解:打表+二分即可. #include <iostream> #inc ...
- HDU 5878 I Count Two Three (预处理+二分查找)
题意:给出一个整数nnn, 找出一个大于等于nnn的最小整数mmm, 使得mmm可以表示为2a3b5c7d2^a3^b5^c7^d2a3b5c7d. 析:预处理出所有形为2a3 ...
- HDU - 5878 2016青岛网络赛 I Count Two Three(打表+二分)
I Count Two Three 31.1% 1000ms 32768K I will show you the most popular board game in the Shanghai ...
- I Count Two Three HDU - 5878(暴力二分)
为甚么16年Qingdao Online 都是暴力题emm///... 先暴力预处理 然后lower _bound二分 #include <iostream> #include <c ...
- 【HDU 4372】 Count the Buildings (第一类斯特林数)
Count the Buildings Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- HDU——T 3336 Count the string
http://acm.hdu.edu.cn/showproblem.php?pid=3336 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
- hdu 5056 Boring count
贪心算法.需要计算分别以每个字母结尾的且每个字母出现的次数不超过k的字符串,我们设定一个初始位置s,然后用游标i从头到尾遍历字符串,使用map记录期间各个字母出现的次数,如果以s开头i结尾的字符串满足 ...
随机推荐
- Pycharm
1.下载pycharm-community-3.0.2.exe 2.setting: keymap scheme:快捷键方案,可选择自带的:default:或者选择eclipse的快捷方案. ide ...
- 求和问题总结(leetcode 2Sum, 3Sum, 4Sum, K Sum)
转自 http://tech-wonderland.net/blog/summary-of-ksum-problems.html 前言: 做过leetcode的人都知道, 里面有2sum, 3sum ...
- POJ 1060 Modular multiplication of polynomials(多项式的加减乘除,除法转化成减法来求)
题意:给出f(x),g(x),h(x)的 (最高次幂+1)的值,以及它们的各项系数,求f(x)*g(x)/h(x)的余数. 这里多项式的系数只有1或0,因为题目要求:这里多项式的加减法是将系数相加/减 ...
- 一个很好的php分词类库
PHPAnalysis源程序下载与演示: PHP分词系统 V2.0 版下载 | PHP分词系统演示 | PHPAnalysis类API文档 原文连接地址:http://www.phpbone.co ...
- linux网站推荐
推荐几个Liux中文学些网站. http://www.chinaunix.net/http://linux.cn/http://www.linuxidc.com/
- MySQL错误代码大全【转载】
B.1. 服务器错误代码和消息 服务器错误信息来自下述源文件: 错误消息信息列在share/errmsg.txt文件中."%d"和"%s"分别代表编号和字符串, ...
- java中什么时候该用static修饰方法?有什么好处或者坏处?
当一个方法或者变量需要初始化加载,或者是经常被调用的时候可以加上static.用static修饰的方法可以用类名直接调用,不用的一定要先实例化一个对象然后才可以调用比如 person这个类里面有一个方 ...
- iOS开发--数组
1.sortedArrayUsingSelector (按Key值大小对NSDictionary排序) NSMutableArray *array = [NSMutableArray arrayWit ...
- 如何获取多核、多cpu系统中指定cpu的序列号
如何获取多核.多cpu系统中指定cpu的序列号作者:SkyJacker(转贴请保持完整并注明作者和出处)http://www.cnpack.orgCnPack IV QQ Group: 130970 ...
- AO总结10:MapControl控件
MapControl对应ArcMap中的数据视图,它封装了Map对象,并提供了额外的属性.方法.事件用于: 1 管理控件的外观.显示属性和地图属性 2 添加并管理控件中的数据层 3 装载Map文档控件 ...