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的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 一本通1619【例 1】Prime Distance

    1619: [例 1]Prime Distance 题目描述 原题来自:Waterloo local,题面详见 POJ 2689 给定两个整数 L,R,求闭区间 [L,R] 中相邻两个质数差值最小的数 ...

  3. 【27.85%】【codeforces 743D】Chloe and pleasant prizes

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. 【34.88%】【codeforces 569C】Primes or Palindromes?

    time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【codeforces 755A】PolandBall and Hypothesis

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 604D】Moodular Arithmetic

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【codeforces 749A】Bachgold Problem

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  8. 【Codeforces 947A】 Primal Sport

    [题目链接] 点击打开链接 [算法] 不难看出,x1的范围是[x2-P(x2)+1,x2],x0的范围是[x1-P(x1)+1,x1] 我们可以先做一遍线性筛,然后暴力就可以了 [代码] #inclu ...

  9. 【Codeforces 776B】Sherlock and his girlfriend

    [题目链接] 点击打开链接 [算法] 将所有质数染成1,合数染成2即可 [代码] #include<bits/stdc++.h> using namespace std; #define ...

随机推荐

  1. Matlab 如何输入矩阵

    A=[1 2 3;4 5 6;7 8 9],每行之间用分号隔开 也可以用循环控制输入 n=input('请输入矩阵阶数:') for i=1:n     for j=1:n         a(i,j ...

  2. RyuJIT的华丽转身【译文】

    2018-06-19 RyuJIT是作为.NET即时编译器的代号称谓,它是.NET运行时的基本组件之一.与此相反的是,Roslyn作为C#编译器,其编译C#代码成为IL字节码.然后,其再将IL字节码编 ...

  3. canvas-3linearGradient.html

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 【工具相关】Web-ionic-ionicLab的使用

    一,下载地址为:http://lab.ionic.io/,下载后直接安装即可.图标如下图所示: 二,打开ionicLab,如下图所示: 三,打开一个已有的文件,File-->Open Exist ...

  5. opencv学习网站[国外网站]+ 各种学习资料

    1.Learn OpenCV 使用C++和python和opencv结合编写的教程,上面有丰富的小实验,并且有完整的源码. 2.pyimagesearch python+opencv编写的实例教程,有 ...

  6. mac挂载分区包括EFI 或者任何隐藏分区

    1.mac终端下的diskutil命令是用来操作磁盘的 diskutil list #显示当前pc所有的磁盘 2.例如我们要挂载u盘中的efi分区 ,确定你的efi分区的 identified 我的是 ...

  7. LeetCode题解之 Find Mode in Binary Search Tree

    1.题目描述 2.问题分析 使用map记录元素出现的次数. 3.代码 vector<int> v; map<int,int> m; vector<int> find ...

  8. python第六十五天--python操作mysql

    pymysql模块对mysql进行 import pymysql # 创建连接 conn = pymysql.connect(host='127.0.0.1', port=3306, user='ro ...

  9. 移动端上拉加载,下拉刷新效果Demo

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. SQLSERVER 死锁

    select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tra ...