【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 ...
随机推荐
- 在C#中的构造函数和解析函数
构造函数 class A() { A() {Console.write("构造函数");} } 当你在程序种出现 A a=new A();的时候 程序自动执行 构造函数 A() { ...
- Rarely executed and almost empty if statement drastically reduces performance in C++
Question: Editor's clarification: When this was originally posted, there were two issues: Test perfo ...
- webpack4 系列教程(一): 打包JS
webpack 本身就是为了打包js所设计,作为第一节,介绍怎么打包js. 1. 检验webpack规范支持 webpack支持es6, CommonJS, AMD. 创建vendor文件夹,其中mi ...
- JMeter 参数化之利用JDBCConnectionConfiguration从数据库读取数据并关联变量
参数化之利用DBC Connection Configuration从数据库读取数据并关联变量 by:授客 QQ:1033553122 1. 下载mysql jar包 下载mysql jar包 ...
- beego+vue.js分离开发,结合发布,简单部署
大家知道,golang开发的东西部署简单是它很大的卖点,一般的应用,生成的可执行文件直接放服务器上运行即可,不需要任何环境.当然,大型的应用才需要比如mysql,nginx等. 但是当vue.js出现 ...
- 9.4、__del__、__doc__、__dict__、__module__、__getitem__、__setitem__、__delitem__、__str__、__repr__、__call__
相关内容: __del__.__doc__.__dict__.__module__.__getitem__.__setitem__.__delitem__.__str__.__repr__.__cal ...
- [20180403]访问dba_autotask_task无输出问题.txt
[20180403]访问dba_autotask_task无输出问题.txt --//链接http://www.itpub.net/thread-1911421-1-1.html的讨论,还没注意原先的 ...
- [20171107]dbms_shared_pool.pin补充.txt
[20171107]dbms_shared_pool.pin补充.txt --//上午的测试,做一些补充,主要还是一些理解问题. 1.环境:SCOTT@book> @ &r/ver1 P ...
- 选择is或者as操作符而不是做强制类型转换
无论何时,正确选择使用as运算符进行类型转换.比盲目的强制类型转换更安全,而且在运行时效率更高. 用as和is进行转换时,并不是对所有用户定义的类型都能完成,只是在运行时类型和目标类型匹配时,转换才能 ...
- U盘内容被病毒隐藏的解决办法(亲测可用)
前几天用U盘的时候不小心感染上了病毒,用自己的电脑打开后里面只剩下一个U盘的快捷方式,选中显示隐藏文件之后依然没有任何显示,但是查看U盘的属性的时候可以看到,U盘已经使用了300多M,所以就上网查了一 ...