mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-01-23 16:51:59 +00:00
parent
61b9f35904
commit
892d4c6881
71
Luogu/P2421/P2421.cpp
Normal file
71
Luogu/P2421/P2421.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <tuple>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 20;
|
||||
|
||||
int n, max, ans;
|
||||
std::tuple<int, int, int> a[N];
|
||||
|
||||
int exgcd(int a, int b, int& x, int& y) {
|
||||
if (!b) {
|
||||
x = 1, y = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
int g = exgcd(b, a % b, y, x);
|
||||
y -= a / b * x;
|
||||
return g;
|
||||
}
|
||||
|
||||
bool check(int k) {
|
||||
for (int i = 1; i < n; i++) {
|
||||
for (int j = i + 1; j <= n; j++) {
|
||||
int c1, p1, l1, c2, p2, l2;
|
||||
std::tie(c1, p1, l1) = a[i];
|
||||
std::tie(c2, p2, l2) = a[j];
|
||||
|
||||
int a = p1 - p2,
|
||||
b = k,
|
||||
c = c2 - c1;
|
||||
|
||||
int x, y,
|
||||
g = exgcd(a, b, x, y);
|
||||
|
||||
if (c % g) continue;
|
||||
|
||||
a /= g, b = std::abs(b / g), c /= g;
|
||||
x = (x * c % b + b) % b;
|
||||
|
||||
if (x <= std::min(l1, l2)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n;
|
||||
|
||||
for (int i = 1, c, p, l; i <= n; i++) {
|
||||
cin >> std::get<0>(a[i]) >> std::get<1>(a[i]) >> std::get<2>(a[i]);
|
||||
|
||||
max = std::max(max, std::get<0>(a[i]));
|
||||
}
|
||||
|
||||
for (int i = max; i <= 1000000; i++) {
|
||||
if (check(i)) {
|
||||
cout << i << endl;
|
||||
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
Luogu/P2421/data/P2421_1.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_10.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_10.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_2.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_2.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_3.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_4.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_4.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_5.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_5.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_6.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_6.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_7.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_7.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_8.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_8.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_9.ans
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P2421/data/P2421_9.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P2421/data/P2421_9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user