【Codeforces 912E】Prime Gift
Codeforces 912 E
题意:给\(n\leq16\)个素数\(p_1..p_n\),求第\(k\)个所有质因数都在\(n\)个数中的数。
思路:折半搜索。。。我原来胡搞毛搞怎么也搞不动\(16\)的点。。。直到我突然想到了分成两个\(8\)来搞。。。
首先我们发现\(n\leq8\)的我们二分+搜索就可以很简单地解决,那么我们据此来搞搞\(n\leq16\)的点。
我们将这些素数分成\(p_1..p_{\lfloor n/2\rfloor}\)、\(p_{\lfloor n/2\rfloor+1}..p_n\)两部分,那么我们可以先将满足这两部分要求的所有小于等于\(10^{18}\)的数都搜出来。
然后二分答案。\(check\)的时候利用\(two\ pointers\)来求满足两部分之一的数们。
这题搞了好长时间。。。太坑了。。。
【Codeforces 912E】Prime Gift的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 一本通1619【例 1】Prime Distance
1619: [例 1]Prime Distance 题目描述 原题来自:Waterloo local,题面详见 POJ 2689 给定两个整数 L,R,求闭区间 [L,R] 中相邻两个质数差值最小的数 ...
- 【27.85%】【codeforces 743D】Chloe and pleasant prizes
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【34.88%】【codeforces 569C】Primes or Palindromes?
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 755A】PolandBall and Hypothesis
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 604D】Moodular Arithmetic
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 749A】Bachgold Problem
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【Codeforces 947A】 Primal Sport
[题目链接] 点击打开链接 [算法] 不难看出,x1的范围是[x2-P(x2)+1,x2],x0的范围是[x1-P(x1)+1,x1] 我们可以先做一遍线性筛,然后暴力就可以了 [代码] #inclu ...
- 【Codeforces 776B】Sherlock and his girlfriend
[题目链接] 点击打开链接 [算法] 将所有质数染成1,合数染成2即可 [代码] #include<bits/stdc++.h> using namespace std; #define ...
随机推荐
- JavaScript一团乱,这是好事
译者按: JavaScript从简单变复杂了,作者从另一个角度看待这个问题. 原文: JavaScript’s a mess – and that’s a good thing 译者: Fundebu ...
- HDU6215
Brute Force Sorting Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Othe ...
- blfs(systemd版本)学习笔记-前几章节的脚本配置
我的邮箱地址:zytrenren@163.com欢迎大家交流学习纠错! 记录blfs书籍前几个章节的配置内容. bash shell启动文件章节 1.切换root用户 su 2.创建/etc/prof ...
- 终端复用软件 tmux
Tmux是一个优秀的终端复用软件,类似GNU Screen,但来自于OpenBSD,采用BSD授权. Tmux 所使用的快捷键前缀默认是组合键 Ctrl-b(同时按下 Ctrl 键和 b 键). 技巧 ...
- mysql 5.7 线程阻塞处理
出现的错误: ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 解决办法: 查看sleep的进程 m ...
- JS的一些小知识
1. 0.1+0.2==0.3? 结果为false 原因:由于计算机是用二进制来存储和处理数据数字,不能精确表示浮点数,而JavaScript是一种弱类型语言,没有相应的封装类来处理浮点数运算 ...
- 原生js实现二级联动下拉列表菜单
二级联动下拉列表菜单的难点在于对后台返回的数据进行解析,不多逼逼,直接上代码 上图是后台返回的数据 实现代码如下: var deviceNotExist = true;//防止数据重复 if(data ...
- Linux 操作系统主机名变成bogon怎么解决?
主机名变成bogon怎么解决? by:授客 QQ:1033553122 一:使用hostname命令 [laiyu@localhost ~]$ hostname localhost.localdo ...
- Mongodb的入门(8)mongodb事物分析
老生常谈:<在前面博客中也介绍过> mongodb官网:https://docs.mongodb.com/manual/introduction/ mongodb:官网上是这样定义的Mon ...
- (后端)Java跨域过滤器
private FilterConfig config = null; @Override public void init(FilterConfig config) throws ServletEx ...