結果

問題 No.1043 直列大学
ユーザー leaf_1415
提出日時 2020-05-01 21:41:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,470 bytes
コンパイル時間 967 ms
コンパイル使用メモリ 78,804 KB
実行使用メモリ 159,616 KB
最終ジャッジ日時 2024-12-22 19:24:25
合計ジャッジ時間 4,821 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007
using namespace std;
typedef pair<llint, llint> P;
llint n, m;
llint v[105], r[105];
llint a, b;
llint dp[105][100005], dp2[105][100005];
void calc(llint a[], llint n, llint dp[105][100005])
{
dp[0][0] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j < 100005; j++){
(dp[i+1][j] += dp[i][j]) %= mod;
if(j+a[i+1] < 100005) (dp[i+1][j+a[i+1]] += dp[i][j]) %= mod;
}
}
}
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++) cin >> v[i];
for(int i = 1; i <= m; i++) cin >> r[i];
cin >> a >> b;
calc(v, n, dp);
calc(r, m, dp2);
for(int i = 1; i < 100005; i++) dp[n][i] += dp[n][i-1], dp[n][i] %= mod;
llint ans = 0;
for(int i = 1; i < 100005; i++){
ans += dp2[m][i] * dp[n][min(100004LL, b*i)] % mod, ans %= mod;
ans += mod - dp2[m][i] * dp[n][min(100004LL, a*i-1)] % mod, ans %= mod;
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0