結果

問題 No.1186 長方形の敷き詰め
ユーザー yudedakoyudedako
提出日時 2020-08-22 17:35:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,182 bytes
コンパイル時間 1,058 ms
コンパイル使用メモリ 107,272 KB
実行使用メモリ 26,632 KB
最終ジャッジ日時 2024-04-23 11:27:12
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 39 ms
26,476 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 14 ms
10,624 KB
testcase_18 AC 25 ms
18,304 KB
testcase_19 AC 30 ms
21,180 KB
testcase_20 AC 31 ms
23,504 KB
testcase_21 AC 23 ms
17,280 KB
testcase_22 AC 39 ms
26,600 KB
testcase_23 AC 22 ms
16,128 KB
testcase_24 AC 32 ms
23,524 KB
testcase_25 AC 20 ms
16,000 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>
#include <complex>

constexpr long long int MOD{ 998244353 };
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<long long int> factorial(m + 1, 1), div(m + 1, 1), inv(m + 1, 1);
	for (auto i = 2; i <= m; ++i) {
		factorial[i] = i * factorial[i - 1] % MOD;
		div[i] = (MOD - MOD / i) * div[MOD % i] % MOD;
		inv[i] = div[i] * inv[i - 1] % MOD;
	}
	const auto combination = [&factorial, &inv](const int n, const int r) {return factorial[n] * inv[r] % MOD * inv[n - r] % MOD; };
	if (n >= m) {
		std::cout << 1 << '\n'; return 0;
	}
	else {
		long long int result{ 0 };
		for (auto i = 0; i <= m / n; ++i) {
			const auto j = m - i * n;
			result = (result + combination(i + j, i)) % MOD;
		}
		std::cout << result << '\n';
	}
}
0