0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 15:58:47 +00:00

Compare commits

...

2 Commits

42 changed files with 236 additions and 0 deletions

58
LibreOJ/2221/2221.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
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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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.