結果

問題 No.1043 直列大学
ユーザー Asdf_QwertyZAsdf_QwertyZ
提出日時 2020-08-07 01:34:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,529 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 84,172 KB
実行使用メモリ 7,308 KB
最終ジャッジ日時 2023-10-22 04:53:02
合計ジャッジ時間 3,175 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,036 KB
testcase_01 AC 4 ms
6,036 KB
testcase_02 AC 5 ms
6,040 KB
testcase_03 AC 5 ms
6,036 KB
testcase_04 AC 5 ms
6,036 KB
testcase_05 AC 5 ms
6,036 KB
testcase_06 AC 5 ms
6,036 KB
testcase_07 AC 5 ms
6,036 KB
testcase_08 AC 5 ms
6,036 KB
testcase_09 AC 15 ms
6,112 KB
testcase_10 AC 18 ms
6,156 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 26 ms
6,816 KB
testcase_15 AC 27 ms
6,816 KB
testcase_16 AC 25 ms
6,796 KB
testcase_17 AC 20 ms
6,480 KB
testcase_18 AC 19 ms
6,696 KB
testcase_19 WA -
testcase_20 AC 20 ms
6,696 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 15 ms
6,348 KB
testcase_28 WA -
testcase_29 AC 10 ms
6,164 KB
testcase_30 AC 17 ms
6,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, M;
ll V[110], R[110];
ll A, B;
ll flV[100010], flR[100010];
mint S[100010];
std::vector<ll> vs, rs;

int main() {
  std::cin >> N >> M;

  rep( i, N )
    std::cin >> V[i];
  
  rep( i, M )
    std::cin >> R[i];

  std::cin >> A >> B;

  flV[0] = 1;

  rep( i, N ) repd( j, 100001 ) {
    if( j+V[i] <= 100000 )
      flV[j+V[i]] += flV[j];
  }

  flR[0] = 1;

  rep( i, M ) repd( j, 100001 ) {
    if( j+R[i] <= 100000 )
      flR[j+R[i]] += flR[j];
  }

  repi( j, 1, 100001 ) {
    if( flR[j] )
      rs.emplace_back( j );

    if( flV[j] )
      vs.emplace_back( j );
  }

  rep( i, vs.size() )
    S[i+1] = S[i]+flV[vs[i]];

  mint ans = 0;

  for( auto r : rs ) {
    ll lb = std::lower_bound( all(vs), A*r )-vs.begin();
    ll rb = std::upper_bound( all(vs), B*r )-vs.begin();
    ans += mint(flR[r])*(S[rb]-S[lb]);
  }

  std::cout << ans.x << endl;

  return 0;
}
0