結果

問題 No.1043 直列大学
ユーザー tanimani364tanimani364
提出日時 2020-05-02 19:59:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,160 bytes
コンパイル時間 2,397 ms
コンパイル使用メモリ 203,688 KB
実行使用メモリ 168,284 KB
最終ジャッジ日時 2023-08-30 03:09:39
合計ジャッジ時間 28,061 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 46 ms
167,896 KB
testcase_02 AC 48 ms
167,916 KB
testcase_03 AC 46 ms
168,072 KB
testcase_04 AC 45 ms
167,992 KB
testcase_05 AC 47 ms
167,948 KB
testcase_06 AC 46 ms
167,852 KB
testcase_07 AC 47 ms
167,916 KB
testcase_08 AC 47 ms
167,912 KB
testcase_09 AC 79 ms
167,900 KB
testcase_10 AC 87 ms
167,848 KB
testcase_11 RE -
testcase_12 AC 114 ms
167,832 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

ll dp[105][100005], dp2[105][100005];
void solve()
{
  int n,m;
  cin >> n >> m;
  vector<ll> v(n), r(m);
  rep(i, n) cin >> v[i];
  rep(i, m) cin >> r[i];
  ll a, b;
  cin >> a >> b;
  memset(dp,0, sizeof(dp));
  memset(dp2, 0, sizeof(dp2));
  dp[0][0] = 1;
  dp2[0][0] = 1;
  rep(i, n)
  {
    rep(j,100001){
      if(j+v[i]<=100000){
        dp[i + 1][j + v[i]] += dp[i][j];
        dp[i + 1][j + v[i]] %= mod;
      }
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= mod;
    }
  }
  rep(i,m){
    rep(j,100001){
      if(j+r[i]<=100000){
        dp2[i + 1][j + r[i]] += dp2[i][j];
        dp2[i + 1][j + r[i]] %= mod;
      }
      dp2[i + 1][j] += dp2[i][j];
      dp2[i + 1][j] %= mod;
    }
  }
  ll ans = 0;
  vector<ll> sum(100005);
  rep(i,100000){
    sum[i + 1] = sum[i] + dp[n][i+1];
    sum[i + 1] %= mod;
  }
  for (ll i = 1; i <= 100000; ++i)
  {
    ans+=(((sum[min(100000LL,i*b)]-sum[i*a-1]+mod)%mod)*dp2[m][i])%mod;
    ans %= mod;
  }
  cout << ans << endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}

0