mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 21:48:48 +00:00
3613. [Heoi2014] 南园满地堆轻絮
https://hydro.ac/d/bzoj/record/6322c03f32ae6c3198cc6a1d
This commit is contained in:
parent
78a6e72b66
commit
32ca556536
58
BZOJ/3613/3613.cpp
Normal file
58
BZOJ/3613/3613.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
BZOJ/3613/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/3613/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/3613/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user