結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2020-05-01 22:28:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 2,481 bytes |
| コンパイル時間 | 1,329 ms |
| コンパイル使用メモリ | 95,492 KB |
| 最終ジャッジ日時 | 2025-01-10 05:09:28 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
struct ModInt {
ModInt() : i(0) {}
ModInt(ll k) : i(k % Mod) {}
ModInt operator+(ModInt m) const {
ModInt r;
r.i = i + m.i;
if (r.i >= Mod) r.i -= Mod;
return r;
}
ModInt operator-(ModInt m) const {
ModInt r;
r.i = i - m.i;
if (r.i < 0) r.i += Mod;
return r;
}
ModInt operator*(ModInt m) const {
ModInt r;
r.i = (ll)i * m.i % Mod;
return r;
}
ModInt &operator+=(ModInt m) {
i += m.i;
if (i >= Mod) i -= Mod;
return *this;
}
ModInt &operator-=(ModInt m) {
i -= m.i;
if (i < 0) i += Mod;
return *this;
}
ModInt &operator*=(ModInt m) {
i = (ll)i * m.i % Mod;
return *this;
}
ModInt operator-() const {
ModInt r;
r.i = i == 0 ? 0 : Mod - i;
return r;
}
ModInt pow(ll k) const {
ModInt r = 1, t = *this;
for (; k != 0; k /= 2) {
if (k & 1) r *= t;
t *= t;
}
return r;
}
////Modが素数のときのみ
//ModInt inv() const {
// return pow(Mod - 2);
//}
//ModInt operator/(ModInt m) const {
// return *this * m.inv();
//}
//ModInt &operator/=(ModInt m) {
// return *this *= m.inv();
//}
constexpr static inline int Mod = 1000000007;
int i;
};
int main() {
int n, m;
cin >> n >> m;
vector<int> v(n), r(m);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < m; i++) {
cin >> r[i];
}
int a, b;
cin >> a >> b;
int l = (int)1e5;
vector<ModInt> x(l + 2), y(l + 1);
x[0] = 1;
for (int i = 0; i < n; i++) {
int t = v[i];
for (int j = l - t; j >= 0; j--) {
x[j + t] += x[j];
}
}
for (int j = l; j >= 0; j--) {
x[j] += x[j + 1];
}
y[0] = 1;
for (int i = 0; i < m; i++) {
int t = r[i];
for (int j = l - t; j >= 0; j--) {
y[j + t] += y[j];
}
}
ModInt s = 0;
for (int j = 1; j <= l; j++) {
ll a1 = min((ll)a * j, (ll)l + 1);
ll b1 = min((ll)b * j + 1, (ll)l + 1);
s += (x[a1] - x[b1]) * y[j];
}
cout << s.i << endl;
return 0;
}
merom686