ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207901 | #3712. Seeker Temple | drdilyor | 100 | 1549ms | 34064kb | C++ | 1.1kb | 2024-08-01 09:36:36 | 2024-08-01 12:38:25 |
answer
/**
Author: 丘成桐(囯内)
**/
#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
int n,k,mid,res;
int a[20];
vector<int> v;
void dfs1(int x,int s){
if(x==n/2+1){
v.push_back(s);
return;
}
for(int i=0;s<=(int)1e18;i++){
dfs1(x+1,s);
if(s<=(int)1e18/a[x])s*=a[x];
else break;
}
}
void dfs2(int x,int s){
if(x==n+1){
//<=mid/s
//cout<<s<<"\n";
int l=0,r=(int)v.size()-1;
int qr=-1;
while(l<=r){
int p=(l+r)/2;
if(v[p]<=mid/s){qr=p;l=p+1;}
else r=p-1;
}
res+=qr+1;
return;
}
for(int i=0;;i++){
dfs2(x+1,s);
if(s<=mid/a[x])s*=a[x];
else break;
}
}
bool check(int x){
mid=x;
//能组成的 <=x 的数的个数 >=k.
res=0;
dfs2(n/2+1,1);
return res>=k;
}
signed main(){
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
cin>>k;
sort(a+1,a+n+1);
dfs1(1,1);
sort(v.begin(),v.end());
int l=1,r=1e18;
int rr=0;
while(l<=r){
int mid=(l+r)/2;
if(check(mid)){
rr=mid,r=mid-1;
}
else l=mid+1;
}
cout<<rr<<"\n";
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 179ms
memory: 17560kb
input:
16 2 5 7 17 23 29 31 41 43 47 59 61 67 71 89 97 4177
output:
185150
result:
ok 1 number(s): "185150"
Test #2:
score: 10
Accepted
time: 47ms
memory: 5248kb
input:
16 5 13 17 19 23 37 41 43 53 59 61 67 71 73 83 97 1136
output:
152693
result:
ok 1 number(s): "152693"
Test #3:
score: 10
Accepted
time: 123ms
memory: 9444kb
input:
15 2 5 7 11 13 29 31 37 47 53 59 61 71 79 89 27760
output:
9506336
result:
ok 1 number(s): "9506336"
Test #4:
score: 10
Accepted
time: 106ms
memory: 9440kb
input:
16 3 7 11 17 19 23 29 37 41 43 59 61 67 71 79 83 15513
output:
9046527
result:
ok 1 number(s): "9046527"
Test #5:
score: 10
Accepted
time: 2ms
memory: 1300kb
input:
8 7 31 53 59 61 67 73 79 33053
output:
8263273940946857
result:
ok 1 number(s): "8263273940946857"
Test #6:
score: 10
Accepted
time: 3ms
memory: 1280kb
input:
8 13 29 37 41 47 61 73 79 66707
output:
904399311706295197
result:
ok 1 number(s): "904399311706295197"
Test #7:
score: 10
Accepted
time: 5ms
memory: 1308kb
input:
7 3 5 11 17 59 61 79 209466
output:
904010601099684375
result:
ok 1 number(s): "904010601099684375"
Test #8:
score: 10
Accepted
time: 359ms
memory: 17560kb
input:
15 2 3 5 7 13 19 29 43 59 71 73 79 83 89 97 140325038
output:
984828581062759296
result:
ok 1 number(s): "984828581062759296"
Test #9:
score: 10
Accepted
time: 261ms
memory: 17560kb
input:
16 2 5 7 17 19 41 43 47 53 59 61 67 73 79 83 89 79756884
output:
992695529294818384
result:
ok 1 number(s): "992695529294818384"
Test #10:
score: 10
Accepted
time: 464ms
memory: 34064kb
input:
15 2 3 5 7 11 17 23 29 43 47 59 73 79 83 89 198534643
output:
921655390703146000
result:
ok 1 number(s): "921655390703146000"