mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:11:58 +00:00
parent
bacfa27ddb
commit
b8abdee1dc
58
LibreOJ/2221/2221.cpp
Normal file
58
LibreOJ/2221/2221.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 5e6 + 5;
|
||||
|
||||
int n, s_a, s_b, s_c, s_d, a[N], b[N], mod, ans;
|
||||
|
||||
inline int f(int x) {
|
||||
return (static_cast<long long>(s_a) % mod * x % mod * x % mod * x % mod
|
||||
+ static_cast<long long>(s_b) % mod * x % mod * x % mod
|
||||
+ static_cast<long long>(s_c) % mod * x % mod
|
||||
+ s_d)
|
||||
% mod;
|
||||
}
|
||||
|
||||
bool check(int x) {
|
||||
std::copy_n(a + 1, n, b + 1);
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
b[i] = std::max(b[i - 1], b[i] - x);
|
||||
|
||||
if (std::abs(a[i] - b[i]) > x) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> s_a >> s_b >> s_c >> s_d >> a[1] >> mod;
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
a[i] = (f(a[i - 1]) + f(a[i - 2])) % mod;
|
||||
}
|
||||
|
||||
int l = 0, r = mod;
|
||||
|
||||
while (l <= r) {
|
||||
int mid = l + r >> 1;
|
||||
|
||||
if (check(mid)) {
|
||||
ans = mid;
|
||||
r = mid - 1;
|
||||
} else {
|
||||
l = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
LibreOJ/2221/data/musique1.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique1.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique10.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique10.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique2.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique2.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique3.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique3.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique4.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique4.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique5.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique5.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique6.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique6.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique7.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique7.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique8.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique8.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique9.in
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
LibreOJ/2221/data/musique9.out
(Stored with Git LFS)
Normal file
BIN
LibreOJ/2221/data/musique9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user