結果

問題 No.1043 直列大学
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-10 23:41:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,717 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 202,532 KB
実行使用メモリ 179,444 KB
最終ジャッジ日時 2023-09-06 00:41:47
合計ジャッジ時間 5,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
179,164 KB
testcase_01 AC 45 ms
179,240 KB
testcase_02 AC 46 ms
179,160 KB
testcase_03 AC 45 ms
179,188 KB
testcase_04 AC 45 ms
179,312 KB
testcase_05 AC 46 ms
179,240 KB
testcase_06 AC 46 ms
179,172 KB
testcase_07 AC 47 ms
179,188 KB
testcase_08 AC 46 ms
179,180 KB
testcase_09 AC 55 ms
179,356 KB
testcase_10 WA -
testcase_11 AC 73 ms
179,284 KB
testcase_12 AC 79 ms
179,280 KB
testcase_13 WA -
testcase_14 AC 72 ms
179,208 KB
testcase_15 WA -
testcase_16 AC 70 ms
179,304 KB
testcase_17 AC 61 ms
179,196 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 79 ms
179,356 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 52 ms
179,176 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

constexpr int MOD = 1e9+7;
//constexpr int MOD = 998244353;

struct mint {
long long x;
  mint(long long x = 0) noexcept : x((x%MOD + MOD) % MOD) {}

  // basis
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) noexcept { if((x += a.x) >= MOD) x -= MOD; return *this; }
  mint& operator-=(const mint a) noexcept { if((x += MOD-a.x) >= MOD) x -= MOD; return *this; }
  mint& operator*=(const mint a) noexcept { (x *= a.x) %= MOD; return *this; }
  mint operator+(const mint a) const noexcept { return mint(*this) += a; }
  mint operator-(const mint a) const noexcept { return mint(*this) -= a; }
  mint operator*(const mint a) const noexcept { return mint(*this) *= a; }
  mint mpow(long long t) const noexcept {
    if(!t) return 1;
    mint a = mpow(t>>1);
    a *= a;
    if(t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const noexcept { return mpow(MOD-2); }
  mint& operator/=(const mint a) noexcept { return *this *= a.inv(); }
  mint operator/(const mint a) const noexcept { return mint(*this) /= a; }

  // comparison
  bool operator==(const mint &a) const noexcept { return this->x == a.x; }
  bool operator!=(const mint &a) const noexcept { return this->x != a.x; }

  // I/O stream
  friend istream& operator>>(istream& is, mint& a) noexcept { return is >> a.x; }
  friend ostream& operator<<(ostream& os, const mint& a) noexcept { return os << a.x; }
};
// additional
mint mpow(const long long &a, long long n) noexcept { return mint(a).mpow(n); }
mint mpow(const mint &a, long long n) noexcept { return a.mpow(n); }


ll n, m, v[100], r[100], a, b;
mint dpv[110][102000], dpr[110][102000];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n >> m;
  rep(i, n) cin >> v[i];
  rep(i, m) cin >> r[i];
  cin >> a >> b;
  dpv[0][0] = 1;
  rep(i, n) rep(j, n*1000+1) {
    dpv[i+1][j] += dpv[i][j];
    dpv[i+1][j+v[i]] += dpv[i][j];
  }
  dpr[0][0] = 1;
  rep(i, m) rep(j, m*1000+1) {
    dpr[i+1][j] += dpr[i][j];
    dpr[i+1][j+r[i]] += dpr[i][j];
  }
  vector<mint> sum(102000, 0);
  rep(i, 101500) sum[i+1] += sum[i]+dpv[n][i];
  mint ans = 0;
  rep(i, 100001) {
    if(a*i > 100000) continue;
    mint cnt = sum[min(100000LL, b*i)+1]-sum[a*i];
    ans += cnt*dpr[n][i];
  }
  ans -= 1;
  cout << ans << '\n';
  return 0;
}
0