結果

問題 No.2079 aaabbc
ユーザー FromBooskaFromBooska
提出日時 2023-06-19 15:39:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 71,580 KB
最終ジャッジ日時 2023-09-09 10:53:00
合計ジャッジ時間 3,284 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,496 KB
testcase_01 AC 68 ms
71,268 KB
testcase_02 AC 67 ms
71,560 KB
testcase_03 AC 68 ms
71,484 KB
testcase_04 AC 67 ms
71,108 KB
testcase_05 AC 72 ms
71,112 KB
testcase_06 AC 69 ms
71,580 KB
testcase_07 AC 68 ms
71,156 KB
testcase_08 AC 66 ms
71,344 KB
testcase_09 AC 66 ms
71,272 KB
testcase_10 AC 64 ms
71,352 KB
testcase_11 AC 66 ms
71,320 KB
testcase_12 AC 67 ms
71,376 KB
testcase_13 AC 67 ms
71,116 KB
testcase_14 AC 68 ms
71,164 KB
testcase_15 AC 68 ms
71,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# N<10**9と大きい
# つまりA, B, Cの最大数だけの全探索だけでも不可能、それなのに二重ループはさらに不可能
# 式変形が必要な問題だろうか
# Σ(A from 0 to N)Σ(B from 0 to N-A)N!/(A!B!(N-A-B)!)
# = Σ(A from 0 to N)N!/A!Σ(B from 0 to N-A)1/(B!(N-A-B)!)
# Aの全探索できないのにこれでは改善している感じがしない
# 解説見たら超簡単だった、悲しい
# N個の文字それぞれが3つの文字のどれかなのだから答えは3**N
# 低い数で実験すべきだった

N = int(input())
mod = 998244353
ans = pow(3, N, mod)
print(ans)
0