結果
問題 | No.1043 直列大学 |
ユーザー | rniya |
提出日時 | 2020-05-30 16:44:02 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 181 ms / 2,000 ms |
コード長 | 3,864 bytes |
コンパイル時間 | 1,670 ms |
コンパイル使用メモリ | 172,736 KB |
実行使用メモリ | 162,224 KB |
最終ジャッジ日時 | 2024-12-22 20:07:59 |
合計ジャッジ時間 | 5,724 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
8,588 KB |
testcase_01 | AC | 5 ms
7,164 KB |
testcase_02 | AC | 12 ms
13,372 KB |
testcase_03 | AC | 6 ms
7,040 KB |
testcase_04 | AC | 6 ms
7,036 KB |
testcase_05 | AC | 6 ms
7,160 KB |
testcase_06 | AC | 5 ms
7,164 KB |
testcase_07 | AC | 9 ms
10,268 KB |
testcase_08 | AC | 9 ms
10,268 KB |
testcase_09 | AC | 91 ms
83,856 KB |
testcase_10 | AC | 109 ms
99,524 KB |
testcase_11 | AC | 161 ms
148,744 KB |
testcase_12 | AC | 181 ms
162,224 KB |
testcase_13 | AC | 149 ms
135,568 KB |
testcase_14 | AC | 158 ms
143,316 KB |
testcase_15 | AC | 176 ms
156,676 KB |
testcase_16 | AC | 158 ms
140,096 KB |
testcase_17 | AC | 113 ms
103,396 KB |
testcase_18 | AC | 116 ms
103,492 KB |
testcase_19 | AC | 151 ms
132,256 KB |
testcase_20 | AC | 111 ms
101,028 KB |
testcase_21 | AC | 137 ms
122,216 KB |
testcase_22 | AC | 143 ms
127,668 KB |
testcase_23 | AC | 178 ms
160,548 KB |
testcase_24 | AC | 126 ms
113,604 KB |
testcase_25 | AC | 147 ms
134,000 KB |
testcase_26 | AC | 161 ms
143,380 KB |
testcase_27 | AC | 79 ms
71,292 KB |
testcase_28 | AC | 151 ms
132,212 KB |
testcase_29 | AC | 49 ms
44,720 KB |
testcase_30 | AC | 112 ms
100,276 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; const long long MOD=1e9+7,MAX=1e5+10; template<uint_fast64_t Modulus> class modint{ using u64=uint_fast64_t; public: u64 a; constexpr modint(const u64 x=0) noexcept:a(((x%Modulus)+Modulus)%Modulus){} constexpr u64 &value() noexcept{return a;} constexpr const u64 &value() const noexcept{return a;} constexpr modint &operator+=(const modint &rhs) noexcept{ a+=rhs.a; if (a>=Modulus) a-=Modulus; return *this; } constexpr modint operator+(const modint &rhs) const noexcept{ return modint(*this)+=rhs; } constexpr modint &operator++() noexcept{ return ++a,*this; } constexpr modint operator++(int) noexcept{ modint t=*this; return ++a,t; } constexpr modint &operator-=(const modint &rhs) noexcept{ if (a<rhs.a) a+=Modulus; a-=rhs.a; return *this; } constexpr modint operator-(const modint &rhs) const noexcept{ return modint(*this)-=rhs; } constexpr modint &operator--() noexcept{ return --a,*this; } constexpr modint operator--(int) noexcept{ modint t=*this; return --a,t; } constexpr modint &operator*=(const modint &rhs) noexcept{ a=a*rhs.a%Modulus; return *this; } constexpr modint operator*(const modint &rhs) const noexcept{ return modint(*this)*=rhs; } constexpr modint &operator/=(modint rhs) noexcept{ u64 exp=Modulus-2; while(exp){ if (exp&1) *this*=rhs; rhs*=rhs; exp>>=1; } return *this; } constexpr modint operator/(const modint &rhs) const noexcept{ return modint(*this)/=rhs; } constexpr modint operator-() const noexcept{ return modint(Modulus-a); } constexpr bool operator==(const modint &rhs) const noexcept{ return a==rhs.a; } constexpr bool operator!=(const modint &rhs) const noexcept{ return a!=rhs.a; } constexpr bool operator!() const noexcept{return !a;} friend constexpr modint pow(modint rhs,long long exp) noexcept{ modint res{1}; while(exp){ if (exp&1) res*=rhs; rhs*=rhs; exp>>=1; } return res; } template<class T> friend constexpr modint operator+(T x,modint y) noexcept{ return modint(x)+y; } template<class T> friend constexpr modint operator-(T x,modint y) noexcept{ return modint(x)-y; } template<class T> friend constexpr modint operator*(T x,modint y) noexcept{ return modint(x)*y; } template<class T> friend constexpr modint operator/(T x,modint y) noexcept{ return modint(x)/y; } friend ostream &operator<<(ostream &s,const modint &rhs) noexcept{ return s << rhs.a; } friend istream &operator>>(istream &s,modint &rhs) noexcept{ u64 a; rhs=modint{(s >> a,a)}; return s; } }; using mint=modint<MOD>; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N,M; cin >> N >> M; vector<vector<mint>> dpv(N+1,vector<mint>(MAX,0)) ,dpr(M+1,vector<mint>(MAX,0)); dpv[0][0]=dpr[0][0]=1; for (int i=0;i<N;++i){ int V; cin >> V; for (int j=0;j<MAX;++j){ dpv[i+1][j]+=dpv[i][j]; if (j+V<MAX) dpv[i+1][j+V]+=dpv[i][j]; } } for (int i=0;i<M;++i){ int C; cin >> C; for (int j=0;j<MAX;++j){ dpr[i+1][j]+=dpr[i][j]; if (j+C<MAX) dpr[i+1][j+C]+=dpr[i][j]; } } int A,B; cin >> A >> B; mint ans=0; vector<mint> sum(MAX,0); for (int i=1;i<MAX;++i) sum[i]=sum[i-1]+dpv[N][i]; for (long long i=1;i<MAX;++i){ ans+=dpr[M][i]*(sum[min(MAX-1,i*B)]-sum[min(MAX-1,i*A-1)]); } cout << ans << '\n'; }