結果
| 問題 | No.3682 きあいのハチマキ |
| コンテスト | |
| ユーザー |
bolero
|
| 提出日時 | 2026-09-05 16:08:49 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| + 476µs | |
| コード長 | 3,000 bytes |
| 記録 | |
| コンパイル時間 | 4,171 ms |
| コンパイル使用メモリ | 378,728 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-09-05 16:08:55 |
| 合計ジャッジ時間 | 5,280 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 |
ソースコード
#if __has_include(<pch/all.h>)
#include <pch/all.h>
#else
#include <bits/stdc++.h>
#include <atcoder/all>
#endif
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No")
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define REVERSE(v) reverse(v.begin(), v.end())
template <typename Container>
void printVector(const Container &v, char delimiter = ' ')
{
for (auto itr = v.begin(); itr != v.end(); itr++)
{
if (itr != v.begin())
{
cout << delimiter;
}
cout << *itr;
}
cout << endl;
}
template <typename Container>
void printlnVector(const Container &v)
{
printVector(v, '\n');
}
void solve()
{
vector<long long> H(2), A(2), S(2);
rep(i, 2)
{
cin >> H[i] >> A[i] >> S[i];
}
vector<long long> k = {
(H[1] + A[0] - 1) / A[0],
(H[0] + A[1] - 1) / A[1],
};
atcoder::modint998244353 one_11 = atcoder::modint998244353{1} / atcoder::modint998244353{11};
atcoder::modint998244353 ten_11 = atcoder::modint998244353{10} / atcoder::modint998244353{11};
atcoder::modint998244353 one_10 = atcoder::modint998244353{1} / atcoder::modint998244353{10};
atcoder::modint998244353 one_100 = atcoder::modint998244353{1} / atcoder::modint998244353{100};
atcoder::modint998244353 nine_10 = atcoder::modint998244353{9} / atcoder::modint998244353{10};
long long delta_k = max(k[0], k[1]) - min(k[0], k[1]);
atcoder::modint998244353 ans = 1;
if (S[0] > S[1])
{
if (k[0] <= k[1])
{
// cout << "???" << endl;
ans = atcoder::modint998244353{9} * ((one_10 * (1 - one_10.pow(delta_k)) / (1 - one_10)) + (one_10.pow(delta_k + 1) / (1 - one_100)));
}
else
{
// cout << "!!!" << endl;
ans = one_10.pow(delta_k) * 9 * one_10 / (1 - one_100);
}
}
if (S[0] < S[1])
{
if (k[0] <= k[1])
{
// cout << "!!!" << endl;
ans = one_10.pow(delta_k) * 9 * one_10 / (1 - one_100);
}
else
{
// cout << "???" << endl;
ans = atcoder::modint998244353{9} * ((one_10 * (1 - one_10.pow(delta_k)) / (1 - one_10)) + (one_10.pow(delta_k + 1) / (1 - one_100)));
}
ans = 1 - ans;
}
if (S[0] == S[1])
{
if (k[0] <= k[1])
{
// cout << "!!!" << endl;
ans = atcoder::modint998244353{1} - atcoder::modint998244353{1} / atcoder::modint998244353{10}.pow(delta_k) / 2;
}
else
{
// cout << "???" << endl;
ans = atcoder::modint998244353{1} / atcoder::modint998244353{10}.pow(delta_k) / 2;
}
}
cout << ans.val() << endl;
}
int main()
{
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
bolero