結果

問題 No.1043 直列大学
ユーザー polylogKpolylogK
提出日時 2020-05-01 22:22:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,393 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 203,776 KB
実行使用メモリ 6,316 KB
最終ジャッジ日時 2023-08-26 14:54:14
合計ジャッジ時間 3,676 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,072 KB
testcase_01 AC 5 ms
5,388 KB
testcase_02 AC 6 ms
5,984 KB
testcase_03 AC 5 ms
5,436 KB
testcase_04 AC 4 ms
5,576 KB
testcase_05 AC 4 ms
5,392 KB
testcase_06 AC 4 ms
5,384 KB
testcase_07 AC 5 ms
6,088 KB
testcase_08 AC 6 ms
5,820 KB
testcase_09 AC 21 ms
6,128 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 31 ms
6,024 KB
testcase_14 AC 32 ms
6,048 KB
testcase_15 AC 35 ms
6,136 KB
testcase_16 AC 31 ms
5,852 KB
testcase_17 AC 24 ms
6,000 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 25 ms
5,856 KB
testcase_25 AC 33 ms
6,056 KB
testcase_26 AC 34 ms
6,132 KB
testcase_27 WA -
testcase_28 AC 31 ms
6,020 KB
testcase_29 AC 13 ms
6,288 KB
testcase_30 AC 24 ms
5,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#ifndef INCLUDED_MODINT_HPP
#define INCLUDED_MODINT_HPP

#include <iostream>

template <std::uint_fast64_t Modulus>
class modint {
	using u32 = std::uint_fast32_t;
	using u64 = std::uint_fast64_t;
	using i64 = std::int_fast64_t;

	inline u64 apply(i64 x) { return (x < 0 ? x + Modulus : x); };

public:
	u64 a;
	static constexpr u64 mod = Modulus;

	constexpr modint(const i64& x = 0) noexcept: a(apply(x % (i64)Modulus)) {}

	constexpr modint operator+(const modint& rhs) const noexcept { return modint(*this) += rhs; }
	constexpr modint operator-(const modint& rhs) const noexcept { return modint(*this) -= rhs; }	
	constexpr modint operator*(const modint& rhs) const noexcept { return modint(*this) *= rhs; }
	constexpr modint operator/(const modint& rhs) const noexcept { return modint(*this) /= rhs; }
	constexpr modint operator^(const u64& k) const noexcept { return modint(*this) ^= k; }
	constexpr modint operator^(const modint& k) const noexcept { return modint(*this) ^= k.value(); }
	constexpr modint operator-() const noexcept { return modint(Modulus - a); }
	constexpr modint operator++() noexcept { return (*this) = modint(*this) + 1; }
	constexpr modint operator--() noexcept { return (*this) = modint(*this) - 1; }
	const bool operator==(const modint& rhs) const noexcept { return a == rhs.a; };
	const bool operator!=(const modint& rhs) const noexcept { return a != rhs.a; };
	const bool operator<=(const modint& rhs) const noexcept { return a <= rhs.a; };
	const bool operator>=(const modint& rhs) const noexcept { return a >= rhs.a; };
	const bool operator<(const modint& rhs) const noexcept { return a < rhs.a; };
	const bool operator>(const modint& rhs) const noexcept { return a > rhs.a; };
	constexpr modint& operator+=(const modint& rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) a -= Modulus;
		return *this;
	}
	constexpr modint& operator-=(const modint& rhs) noexcept {
		if (a < rhs.a) a += Modulus;
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint& rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) (*this) *= rhs;
			
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
	constexpr modint& operator^=(u64 k) noexcept {
		auto b = modint(1);
		while(k) {
			if(k & 1) b = b * (*this);
			(*this) *= (*this);
			k >>= 1;
		}
		return (*this) = b;
	}
	constexpr modint& operator=(const modint& rhs) noexcept {
		a = rhs.a;
		return (*this);
	}

	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	explicit operator bool() const { return a; }
	explicit operator u32() const { return a; }

	const modint inverse() const {
		return modint(1) / *this;
	}
	const modint pow(i64 k) const {
		return modint(*this) ^ k;
	}

	friend std::ostream& operator<<(std::ostream& os, const modint& p) {
		return os << p.a;
	}
	friend std::istream& operator>>(std::istream& is, modint& p) {
		u64 t;
		is >> t;
		p = modint(t);
		return is;
	}
};

#endif
using mint = modint<1000000007>;

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> a(n), b(m);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < m; i++) scanf("%d", &b[i]);
	int A, B; scanf("%d%d", &A, &B);

	std::vector<mint> x(1e5 + 1), y(1e5 + 1); x[0] = y[0] = 1;
	for(int l = 0; l < 2; l++) {
		for(int i = 0; i < a.size(); i++) {
			std::vector<mint> nxt(x);

			for(int j = 0; j < x.size(); j++) {
				if(j + a[i] >= x.size()) continue;
			
				nxt[j + a[i]] += x[j];
			}
			x.swap(nxt);
		}

		a.swap(b);
		x.swap(y);
	}

	std::vector<mint> s(x.size() + 1);
	for(int i = 1; i < x.size(); i++) s[i] = s[i - 1] + x[i - 1];

	mint ans = 0;
	for(i64 i = 1; i < y.size(); i++) {
		int L = std::min((i64)x.size() - 1, i * (i64)A);
		int R = std::min((i64)x.size() - 1, i * (i64)B) + 1;
		if(1e5 < i * A) continue;

		ans += (s[R] - s[L]) * y[i];
	}
	printf("%lld\n", ans.value());
	return 0;
}
0