打表,二分。

满足条件的数字个数不多,可以全部找出来,排个序,每次询问的时候二分一下。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-6;
void File()
{freopen("D:\\in.txt","r",stdin);freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{char c=getchar(); x=0;while(!isdigit(c)) c=getchar();while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
}const int maxn=100010;
LL M=2e9;
LL p[maxn];
int sz=0;int main()
{LL a=1;for(int i=0;;i++){if(i!=0) a=a*2; if(a>M) break;LL b=1;for(int j=0;;j++){if(j!=0) b=b*3; if(b>M||a*b>M) break;LL c=1;for(int s=0;;s++){if(s!=0) c=c*5; if(c>M||a*b*c>M) break;LL d=1;for(int k=0;;k++){if(k!=0) d=d*7; if(d>M||a*b*c*d>M) break;p[sz++]=a*b*c*d;}}}}sort(p,p+sz);int T; scanf("%d",&T);while(T--){LL n; scanf("%lld",&n);int L=0,R=sz-1,pos;while(L<=R){int m=(L+R)/2;if(p[m]<n) L=m+1;else if(p[m]==n) { pos=m; break; }else pos=m,R=m-1;}printf("%lld\n",p[pos]);}return 0;
}

转载于:https://www.cnblogs.com/zufezzt/p/5887011.html

HDU 5878 I Count Two Three相关推荐

  1. 【HDU - 5878】I Count Two Three(打表)

    题干: I will show you the most popular board game in the Shanghai Ingress Resistance Team. It all star ...

  2. HDU - 5878 A - I Count Two Three H 技巧枚举

    题意 输入 t (1≤t≤500000), the number of test cases. t test cases follow. Each test case provides one int ...

  3. HDU 6155 Subsequence Count (DP、线性代数、线段树)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=6155 题解 DP+线代好题.(考场上过多时间刚前两题,没怎么想这题--) 首先列出一个DP式: 设\( ...

  4. 【HDU - 6016】Count the Sheep (思维,类似二分图)

    题干: Altough Skipping the class is happy, the new term still can drive luras anxious which is of cour ...

  5. HDU 6155 Subsequence Count(矩阵乘法+线段树+基础DP)

    题意 给定一个长度为 \(n\) 的 \(01\) 串,完成 \(m\) 种操作--操作分两种翻转 \([l,r]\) 区间中的元素.求区间 \([l,r]\) 有多少个不同的子序列. \(1 \le ...

  6. php basename() 绕过,【转】PHP里的basename函数不支持中文名的解决

    今天用到basename 函数获取文件名称时,发现如果是中文的文件名返回只有后缀的空文件名(如:.pdf) string basename ( string path [, string suffix ...

  7. 【HDU】3441 Rotation

    题意:给出A和C(1<=A,C<=10^9),所有满足B * B * K + 1 = A * A, (K >= 0)的B,构成边长为B的正方形,等角度的围绕在一个小正方形的周围.用C ...

  8. 杭电OJ分类题目(2)

    原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(2) HDU Water~~~ HDU 100 ...

  9. 解题报告 (十三) 尺取法

    文章目录 尺取法 解题报告 PKU 2100 Graveyard Design PKU 3061 Subsequence PKU 2739 Sum of Consecutive Prime Numbe ...

最新文章

  1. ClickHouse 学习
  2. Swift中使用正则表达式
  3. Oracle EXPDP/IMPDP示例
  4. php面向对象的构造与构析方法
  5. setsockopt()用法(转载)
  6. html li去掉黑点_10分钟教你Python爬虫(上) HTML和爬虫基础
  7. avs3 ts格式封装 标准_第480期【软件】吊打格式工厂—高清视频转换器WonderFox HD Video便携版...
  8. 图数据库 graph_通过SQL Server中的自连接了解Graph数据库相对于关系数据库的好处
  9. 201612-1-中间数
  10. 组织架构适配下的敏捷开发
  11. Windows 上如何制作简谱
  12. ubuntu dock栏添加应用启动图标
  13. 【数据挖掘】聚类 Cluster 简介 ( 概念 | 应用场景 | 质量 | 相似度 | 算法要求 | 数据矩阵 | 相似度矩阵 | 二模矩阵 | 单模矩阵 )
  14. 前端面试需要准备什么?
  15. C++11 时间编程(3)时间点表示time_point,时钟类型,当前时间获取
  16. Python之基础详解(九):关于VisualMapOpts视觉映射配置项详解
  17. Windows自带截屏-快捷键截图区域至剪切板
  18. 【信号调理】精密检波电路和PCB示例
  19. The Copernicus Global Land Service (CGLS)账号注册与数据下载
  20. 互操作性的区块链系统设计理念

热门文章

  1. 【RAC】 RAC For W2K8R2 安装--总体规划 (一)
  2. 窗口和元素的大小:offset client scroll
  3. 活得太累,只因为你索求的太多
  4. Nacos-快速入门
  5. 同步(Synchronization)和异步(Asynchronous)
  6. 使用Spring 框架能带来哪些好处?
  7. 基于Xml 的IOC 容器-获得配置路径
  8. sorted set 数据类型的应用场景
  9. 类的加载过程二:Linking
  10. show status用法