結果

問題 No.1043 直列大学
ユーザー masutech16masutech16
提出日時 2020-05-01 22:07:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,974 bytes
コンパイル時間 1,438 ms
コンパイル使用メモリ 170,600 KB
実行使用メモリ 14,196 KB
最終ジャッジ日時 2023-08-26 13:57:34
合計ジャッジ時間 3,910 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
13,764 KB
testcase_01 AC 16 ms
13,928 KB
testcase_02 AC 18 ms
13,900 KB
testcase_03 AC 17 ms
13,888 KB
testcase_04 AC 17 ms
13,888 KB
testcase_05 AC 16 ms
13,896 KB
testcase_06 AC 17 ms
13,948 KB
testcase_07 AC 18 ms
13,812 KB
testcase_08 AC 17 ms
13,784 KB
testcase_09 AC 39 ms
14,120 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 57 ms
13,816 KB
testcase_14 AC 60 ms
13,960 KB
testcase_15 AC 64 ms
13,872 KB
testcase_16 AC 57 ms
14,100 KB
testcase_17 AC 46 ms
14,152 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 54 ms
13,952 KB
testcase_22 AC 54 ms
13,788 KB
testcase_23 WA -
testcase_24 AC 51 ms
14,196 KB
testcase_25 AC 56 ms
13,844 KB
testcase_26 AC 60 ms
13,904 KB
testcase_27 AC 37 ms
13,888 KB
testcase_28 AC 56 ms
13,948 KB
testcase_29 AC 27 ms
14,004 KB
testcase_30 AC 47 ms
13,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "/mnt/c/Users/leafc/dev/compro/lib/math/modint.hpp"
#include <cstdint>
#include <iostream>
#ifndef MOD_INT
#define MOD_INT

template <std::uint_fast64_t MOD> class ModInt {
  using u64 = std::uint_fast64_t;

public:
  ModInt(const u64 val = 0) { value = val % MOD; }

  ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }

  ModInt &operator+=(const ModInt rhs) {
    value += rhs.value;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator-=(const ModInt rhs) {
    if (value < rhs.value) {
      value += MOD;
    }
    value -= rhs.value;
    return *this;
  }

  ModInt &operator*=(const ModInt rhs) {
    value = value * rhs.value % MOD;
    return *this;
  }

  ModInt &operator/=(ModInt rhs) {
    *this *= rhs.inv();
    return *this;
  }

  ModInt &operator++(int n) {
    value++;
    if (value >= MOD) {
      value -= MOD;
    }
    return *this;
  }

  ModInt &operator--(int n) {
    if (value == 0) {
      value += MOD;
    }
    value--;
    return *this;
  }

  ModInt inv() { return ModInt::pow(*this, MOD - 2); }

  static ModInt pow(ModInt base, long long int n) {
    ModInt res = ModInt(1);
    while (n) {
      if (n & 1) {
        res *= base;
      }
      base *= base;
      n /= 2;
    }
    return res;
  }

  static ModInt comb(ModInt n, ModInt r) { return comb(n.value, r.value); }

  static ModInt comb(int n, int r) {
    if (n < r)
      return ModInt(0);
    ModInt res = ModInt(1);
    for (int i = 0; i < r; i++) {
      res *= ModInt(n - i);
    }

    ModInt inv = ModInt(1);
    for (int i = 0; i < r; i++) {
      inv *= ModInt(r - i);
    }
    return res / inv;
  }

  u64 getValue() const { return value; }

private:
  u64 value;

  friend std::ostream &operator<<(std::ostream &out, const ModInt<MOD> &m) {
    out << m.value;
    return out;
  }

  friend std::istream &operator>>(std::istream &in, ModInt &m) {
    uint_fast64_t i;
    in >> i;
    m = ModInt(i);
    return in;
  }
};

#endif
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 3 "tmp.cpp"

using mint = ModInt<1000000007>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  vi v(n), r(m);
  REP(i, n) { cin >> v[i]; }
  REP(j, m) { cin >> r[j]; }
  ll a, b;
  cin >> a >> b;

  vector<vector<mint>> dpr(1e5 + 1, vector<mint>(2, mint(0)));
  dpr[0][0] = mint(1);
  FOR(i, 1, m + 1) {
    REP(j, 1e5 + 1) {
      dpr[j][i % 2] = dpr[j][(i - 1) % 2];
      if (j - r[i - 1] >= 0) {
        dpr[j][i % 2] += dpr[j - r[i - 1]][(i - 1) % 2];
      }
    }
  }

  vector<vector<mint>> dpv(1e5 + 1, vector<mint>(2, mint(0)));
  dpv[0][0] = mint(1);
  FOR(i, 1, n + 1) {
    REP(j, 1e5 + 1) {
      dpv[j][i % 2] = dpv[j][(i - 1) % 2];
      if (j - v[i - 1] >= 0) {
        dpv[j][i % 2] += dpv[j - v[i - 1]][(i - 1) % 2];
      }
    }
  }
  FOR(i, 1, 1e5 + 1) { dpv[i][n % 2] += dpv[i - 1][n % 2]; }

  mint ans(0);
  FOR(i, 1, 1e5 + 1) {
    ll low = a * i, high = b * i;
    if (a * i > 1e5 + 1 || b * i > 1e5 + 1)
      continue;
    ans += (dpv[high][n % 2] - dpv[low - 1][n % 2]) * dpr[i][m % 2];
  }
  cout << ans << endl;

  return 0;
}
0