結果
問題 | No.1043 直列大学 |
ユーザー | rniya |
提出日時 | 2020-05-30 16:41:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,852 bytes |
コンパイル時間 | 1,918 ms |
コンパイル使用メモリ | 171,668 KB |
実行使用メモリ | 162,100 KB |
最終ジャッジ日時 | 2024-11-07 19:47:45 |
合計ジャッジ時間 | 12,968 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
8,716 KB |
testcase_01 | AC | 7 ms
7,036 KB |
testcase_02 | AC | 13 ms
13,372 KB |
testcase_03 | AC | 6 ms
7,040 KB |
testcase_04 | AC | 7 ms
7,164 KB |
testcase_05 | AC | 6 ms
7,164 KB |
testcase_06 | AC | 6 ms
7,040 KB |
testcase_07 | AC | 9 ms
10,264 KB |
testcase_08 | AC | 10 ms
10,264 KB |
testcase_09 | AC | 88 ms
83,856 KB |
testcase_10 | AC | 105 ms
99,392 KB |
testcase_11 | AC | 158 ms
148,868 KB |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 114 ms
103,460 KB |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | AC | 134 ms
122,208 KB |
testcase_22 | AC | 143 ms
127,668 KB |
testcase_23 | AC | 178 ms
160,548 KB |
testcase_24 | AC | 122 ms
113,604 KB |
testcase_25 | AC | 146 ms
133,876 KB |
testcase_26 | AC | 154 ms
143,376 KB |
testcase_27 | AC | 79 ms
71,168 KB |
testcase_28 | AC | 143 ms
132,464 KB |
testcase_29 | AC | 47 ms
44,596 KB |
testcase_30 | AC | 109 ms
100,404 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; const int 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 (int 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'; }