0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 13:56:26 +00:00

P4105 [HEOI2014] 南园满地堆轻絮

https://www.luogu.com.cn/record/85674001
This commit is contained in:
Baoshuo Ren 2022-09-02 11:13:40 +08:00
parent b8abdee1dc
commit 2d161dd033
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
21 changed files with 118 additions and 0 deletions

58
Luogu/P4105/P4105.cpp Normal file
View 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
Luogu/P4105/data/P4105_1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/P4105/data/P4105_9.out (Stored with Git LFS) Normal file

Binary file not shown.