数学--数论--HDU--5878 Count Two Three 2016 ACM/ICPC Asia Regional Qingdao Online 1001
时间:2022-07-28
本文章向大家介绍数学--数论--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 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.
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
10
1
11
13
123
1234
12345
123456
1234567
12345678
123456789
Sample Output
1
12
14
125
1250
12348
123480
1234800
12348000
123480000
这个题的意思是让你找到一个k大于n并且能写成 2 a 3 b 5 c 7 d 2^a3^b5^c7^d 2a3b5c7d这种形式。 然后就先把能写成这种形式的数的全部处理出来,在进行二分查找,比这个大的最小的数。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long a[200000];
int d = 0;
int main()
{
int x, y;
d = 0;
memset(a, 0, sizeof(a));
for (int i = 0; i <= 32; i++)
{
for (int j = 0; j <= 19; j++)
{
for (int k = 0; k <= 12; k++)
{
for (int h = 0; h <= 11; h++)
{
long long s = pow(2, i) * pow(3, j) * pow(5, k) * pow(7, h);
if (s > 1000000000 || s < 0)
break;
else
{
a[d++] = s;
}
}
}
}
}
sort(a, a + d);
scanf("%d", &x);
while (x--)
{
scanf("%d", &y);
printf("%lldn", *lower_bound(a, a + d, y));
}
return 0;
}
- WCF 4.0路由服务Routing Service
- ExpandableListView简单应用及listview模拟ExpandableListView
- 文件句柄与文件描述符
- android GifView分享
- VAE、GAN、Info-GAN:全解深度学习三大生成模型
- android获取设备唯一标示
- 如果正确读取SQL Server中的扩展事件?
- android自定义xmls文件属性
- 分布式系统中的RPC请求经常出现乱序的情况 写一个算法来将一个乱序的序列保序输出
- jsoup详解
- 用LogParser对IIS 日志进行分析
- android异步任务asyntask详解
- 在Mono 2.8上部署ASP.NET MVC 2
- java虚拟机构造原理
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Pots(POJ - 3414)【BFS 寻找最短路+路径输出】
- Vue路由Hash模式分析
- Flutter基础widgets教程-CupertinoButton篇
- 利用TfidfVectorizer进行中文文本分类(数据集是复旦中文语料)
- 组合模式
- Js中数组空位问题
- 反转字符串
- Prime Path(POJ - 3126)【BFS+筛素数】
- (leetcode每日打卡)秋叶收藏集【动态规划】
- 设计模式~调停者模式(Mediator)
- Sequential Nim(CodeForces - 1382B)【博弈】
- Less Coin Tosses(Gym - 102346L)【打表+找规律】
- leetcode1558题解【贪心】
- 如何将炫酷的报表直接截图发送邮件——在Superset 0.37使用Schedule Email功能
- Kafka监控必备——Kafka-Eagle 2.0.2正式发布