Initial commit

This commit is contained in:
2025-03-14 22:39:32 +08:00
commit 7b1e0f329e
38 changed files with 1153 additions and 0 deletions

45
15lanqiao/test5.cpp Normal file
View File

@@ -0,0 +1,45 @@
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
vector<int> fac[N], s[N];
int main() {
for(int i = 1; i <= 1e5; i++){
for(int j = i; j <= 1e5; j += i){
fac[j].push_back(i);
}
}
int n; cin>>n;
for(int i = 1; i<=n; i++) cin >> a[i];
// 保证字典序最小
sort(a+1, a+1+n);
for(int i = 1; i <=n; i++){
for(int j = 0; j < fac[a[i]].size(); j++){
s[fac[a[i]][j]].push_back(a[i]);
}
}
for(int i = 1e5; i>=0; i--){
if(s[i].size() >= 3){
cout << s[i][0] << " " << s[i][1] << " " << s[i][2] << endl;
break;
}
}
return 0;
}
/* test samples
5
1 2 3 4 9
*/
/*
排序后的宝石为 [1, 2, 3, 4, 9]。
因数数组 fac 和宝石数组 s 的关系如下:
s[1] 包含所有宝石 [1, 2, 3, 4, 9]。
s[2] 包含 [2, 4]。
s[3] 包含 [3, 9]。
s[4] 包含 [4]。
s[9] 包含 [9]。
最终s[1] 中有5个宝石满足条件。
输出前三个宝石1 2 3。
*/