結果

問題 No.1043 直列大学
ユーザー soto800soto800
提出日時 2020-05-01 22:05:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,664 bytes
コンパイル時間 1,348 ms
コンパイル使用メモリ 167,928 KB
実行使用メモリ 6,780 KB
最終ジャッジ日時 2023-08-26 13:41:50
合計ジャッジ時間 5,309 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,604 KB
testcase_01 AC 6 ms
6,492 KB
testcase_02 AC 7 ms
6,512 KB
testcase_03 AC 6 ms
6,436 KB
testcase_04 AC 6 ms
6,448 KB
testcase_05 AC 6 ms
6,772 KB
testcase_06 AC 6 ms
6,492 KB
testcase_07 AC 7 ms
6,540 KB
testcase_08 AC 6 ms
6,720 KB
testcase_09 AC 17 ms
6,548 KB
testcase_10 AC 20 ms
6,444 KB
testcase_11 RE -
testcase_12 RE -
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 AC 16 ms
6,780 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;

mint dpV[100*1000+100];
mint dpR[100*1000+100];
mint sumV[100*1000+110];
mint sumR[100*1000+110];

int main(){

	lli n,m;
	cin>>n>>m;
	dpV[0]=1;
	dpR[0]=1;
	vector<lli> v(n);
	REP(i,0,n){
		cin>>v[i];
		for(lli j=100*1000;j>=0;j--){
			dpV[v[i]+j] += dpV[j];
		}
	}
	REP(i,0,100*1000+10)sumV[i+1]+=sumV[i]+dpV[i];

	vector<lli> r(m);
	REP(i,0,m){
		cin>>r[i];
		for(lli j=100*1000;j>=0;j--){
			dpR[r[i]+j] += dpR[j];
		}
	}
	REP(i,0,100*1000+10)sumR[i+1]+=sumR[i]+dpR[i];

	lli a,b;
	cin>>a>>b;
	mint ans = 0;
	//Rを固定した方がやりやすい
	REP(r,1,100*1000){
		lli minV = r*a;
		lli maxV = r*b;
		ans += dpR[r]*(sumV[min((lli)(100*1000+10),maxV+1)]-sumV[min((lli)(100*1000+10),minV)]);
	}
	cout<<ans<<endl;

    return 0;
}
0