正解:二分+搜索

解题报告:

传送门$QwQ$

因为翻译真的很$umm$所以还是写下题目大意$QwQ$,就说给定一个大小为$n$的素数集合,求出分解后只含这些质数因子的第$K$小整数

考虑先把质数分两堆,$meet-in-the-middle$搜出每堆能表示的数.

然后二分答案,扫左边的数看右边有多少个数满足相乘小于等于这个$mid$的,将数量全加起来和$K$比较就成.然后这个查看右边的操作,可以直接一个指针扫下,就不用二分做了$QwQ$.

出于一些不知道原因的玄学原因,在$meet-in-the-middle$的时候最好是两个两个跳着搜,,,直接简单粗暴对半搜会$T$我也不知道啥原理$kk$.

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define ll long long
#define t(i) edge[i].to
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt) const int N=+;
const ll mx=1e18;
int n,p[N];
ll K;
vector<ll>V[]; il int read()
{
rc ch=gc;ri x=;rb y=;
while(ch!='-' && (ch>'' || ch<''))ch=gc;
if(ch=='-')ch=gc,y=;
while(ch>='' && ch<='')x=(x<<)+(x<<)+(ch^''),ch=gc;
return y?x:-x;
}
void dfs(ll dat,ri nw,ri num)
{
if(nw>n){V[num].push_back(dat);return;}
dfs(dat,nw+,num);while(dat<=mx/p[nw])dfs(dat*p[nw],nw+,num),dat=1ll*dat*p[nw];
}
il bool check(ll dat)
{
ri sz=V[].size(),nw=V[].size()-,ret=;
rp(i,,sz-){if(V[][i]>dat || !(~nw))break;while(~nw && V[][nw]>dat/V[][i])--nw;ret+=nw+;}
return ret>=K;
} int main()
{
freopen("912e.in","r",stdin);freopen("912e.out","w",stdout);
n=read();rp(i,,n)p[i]=read();K=read();dfs(,,);dfs(,,);
sort(V[].begin(),V[].end());sort(V[].begin(),V[].end());
ll l=,r=mx;while(l<r){ll mid=(l+r)>>;if(check(mid))r=mid;else l=mid+;}
printf("%lld\n",l);
return ;
}

随机推荐

  1. @topcoder - TCO19 Regional Wildcard Wildcard Round - D1L2@ Diophantine

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 令 p[] 为质数序列:p[0] = 2, p[1] = 3, ...

  2. @codeforces - 1205B@ Shortest Cycle

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个长度为 n 的正整数序列 a1, a2, ..., an ...

  3. @loj - 2288@「THUWC 2017」大葱的神力

    目录 @description@ @solution@ @data - 1@ @data - 2@ @data - 3@ @data - 4@ @data - 5@ @data - 6@ @data ...

  4. tomcat不能多次startup.sh,异常时直接,分析logs目录下的日志。

    tomcat不能多次startup.sh,异常时直接干掉其进程. 分析logs目录下的日志.

  5. react项目安装及运行

    博客地址 :https://www.cnblogs.com/sandraryan/ 安装node ,有就跳过. node.js官网:https://nodejs.org/en/ 终端用node -v ...

  6. Python:pip 和pip3的区别

    前言 装完python3后发现库里面既有pip也有pip3,不知道它们的区别,因此特意去了解了一下. 解释 先搜索了一下看到了如下的解释, 安装了python3之后,库里面既会有pip3也会有pip ...

  7. supersockets服务器配置热更新

    Keywords: 配置,热更新 此功能能够允许你在不重启服务器的前提下更新服务器实例的配置. (仅限1.6.5及其以上版本)

  8. js原生继承几种方式

    js原生继承 js本身并没有继承和类的概念,本质上是通过原型链(prototype)的形式实现的. 1.先写两个构造函数Parent和Child,用于将Child继承Parent function P ...

  9. 如何在SpringMVC项目中部署WebService服务并打包生成客户端

    场景 某SpringMVC项目原本为一个HTTP的WEB服务项目,之后想在该项目中添加WebService支持,使该项目同时提供HTTP服务和WebService服务.其中WebService服务通过 ...

  10. H3C 帧中继显示与调试