結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
rniya
|
| 提出日時 | 2020-05-30 16:41:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 RE * 8 |
ソースコード
#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';
}
rniya