Precreation contest files
This commit is contained in:
BIN
misc/tlbdhsg/a.out
Executable file
BIN
misc/tlbdhsg/a.out
Executable file
Binary file not shown.
25
misc/tlbdhsg/b19.cpp
Normal file
25
misc/tlbdhsg/b19.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
unordered_set<int> hash;
|
||||
deque<int> res;
|
||||
|
||||
while (n--) {
|
||||
int x;
|
||||
cin >> x;
|
||||
if (hash.find(x) == hash.end()) {
|
||||
res.push_back(x);
|
||||
hash.insert(x);
|
||||
}
|
||||
}
|
||||
cout << res.size() << '\n';
|
||||
while (!res.empty()) {
|
||||
cout << res.front() << " ";
|
||||
res.pop_front();
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
22
misc/tlbdhsg/b20.cpp
Normal file
22
misc/tlbdhsg/b20.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int n, x, k;
|
||||
cin >> n >> k >> x;
|
||||
cout << n + 1 << '\n';
|
||||
k--;
|
||||
while (n--) {
|
||||
int a;
|
||||
cin >> a;
|
||||
cout << a << ' ';
|
||||
k--;
|
||||
if (!k)
|
||||
cout << x << ' ';
|
||||
}
|
||||
cout << '\n';
|
||||
}
|
||||
4
misc/tlbdhsg/ginny.cpp
Normal file
4
misc/tlbdhsg/ginny.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
int main() {}
|
||||
20
misc/tlbdhsg/stones.cpp
Normal file
20
misc/tlbdhsg/stones.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <bits/stdc++.h>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(NULL);
|
||||
int n;
|
||||
cin >> n;
|
||||
int a = sqrt(n);
|
||||
int b = (n + a - 1) / a;
|
||||
|
||||
int res_a = a, res_b = b;
|
||||
a += 1;
|
||||
b = (n + a - 1) / a;
|
||||
if (a + b < res_a + res_b) {
|
||||
cout << a << " " << b << "\n";
|
||||
} else {
|
||||
cout << res_a << " " << res_b << "\n";
|
||||
}
|
||||
}
|
||||
31
misc/tlbdhsg/stones_t.cpp
Normal file
31
misc/tlbdhsg/stones_t.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
long long n;
|
||||
if (!(cin >> n))
|
||||
return 0;
|
||||
|
||||
// The minimum sum a+b for a*b >= n occurs when a and b are close to sqrt(n)
|
||||
long long a = sqrt(n);
|
||||
long long b = (n + a - 1) / a; // Ceiling division
|
||||
|
||||
// We check if (a+1) provides a better sum
|
||||
// though mathematically, the first integer b near sqrt(n) is usually it.
|
||||
long long res_a = a, res_b = b;
|
||||
|
||||
// Check the neighbor just in case of rounding issues with sqrt
|
||||
long long a2 = a + 1;
|
||||
long long b2 = (n + a2 - 1) / a2;
|
||||
|
||||
if (a2 + b2 < res_a + res_b) {
|
||||
res_a = a2;
|
||||
res_b = b2;
|
||||
}
|
||||
|
||||
cout << res_a << " " << res_b << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user