• 微信公众号：美女很有趣。 工作之余，放松一下，关注即送10G+美女照片！

# 洛谷P2527 Panda的烦恼[搜索]

4小时前 2次浏览

```#include <bits/stdc++.h>
using namespace std;
#define limit (200 + 5)//防止溢出
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f
#define lowbit(i) i&(-i)//一步两步
#define EPS 1e-9
#define FASTIO  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define ff(a) printf("%dn",a );
#define pi(a,b) pair<a,b>
#define rep(i, a, b) for(ll i = a; i <= b ; ++i)
#define per(i, a, b) for(ll i = b ; i >= a  ; --i)
#define MOD 998244353
#define traverse(u) for(int i = head[u]; ~i ; i = edge[i].next)
#define FOPEN freopen("C:\Users\tiany\CLionProjects\akioi\data.txt", "rt", stdin)
#define FOUT freopen("C:\Users\tiany\CLionProjects\akioi\dabiao.txt", "wt", stdout)
#define debug(x) cout<<x<<endl
typedef long long ll;
typedef unsigned long long ull;
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
ll sign = 1, x = 0;char s = getchar();
while(s > '9' || s < '0' ){if(s == '-')sign = -1;s = getchar();}
while(s >= '0' && s <= '9'){x = (x << 3) + (x << 1) + s - '0';s = getchar();}
return x * sign;
#undef getchar
}//快读
void print(ll x) {
if(x/ 10) print(x / 10);
*O++=x % 10+'0';
}
void write(ll x, char c = 't') {
if(x < 0)putchar('-'),x = -x;
print(x);
if(!isalpha(c))*O++ = c;
fwrite(obuf,O-obuf,1,stdout);
O = obuf;
}
int kase;
int n, m,k;
int64_t a[limit];
void solve(){
priority_queue<ll, vector<ll>, greater<>>q;
set<ll>s;
rep(i,1,n){
q.push(a[i]);
s.insert(a[i]);
}
sort(a + 1, a + 1 + n);
if(k <= n){
cout<<a[k]<<endl;
return;
}
vector<ll>stk;
ll lim = 1e10;

while (stk.size() < k - 1){
auto u = q.top();
q.pop();
rep(i,1,n){
if(u * a[i] > lim)break;
if(s.count(u * a[i]))continue;
q.push(u * a[i]);
s.insert(u * a[i]);
}
if(stk.empty())stk.push_back(q.top());
else if(q.top() > stk.back()){
stk.push_back(q.top());
}
}
write(q.top());
}
int32_t main() {
#ifdef LOCAL
// FOPEN;
//    FOUT;
#endif
FASTIO
//    cin>>kase;
//    while (kase--)
solve();
cerr << "Time elapsed: " << 1.0*clock()/CLOCKS_PER_SEC << "sn";
return 0;
}```