結果

問題 No.2302 Carry X Times
ユーザー titiatitia
提出日時 2023-05-13 05:01:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 498 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 10,356 KB
最終ジャッジ日時 2023-08-19 09:12:46
合計ジャッジ時間 9,600 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 236 ms
9,496 KB
testcase_01 AC 74 ms
8,752 KB
testcase_02 AC 81 ms
8,912 KB
testcase_03 AC 20 ms
8,536 KB
testcase_04 AC 20 ms
8,528 KB
testcase_05 AC 21 ms
8,680 KB
testcase_06 AC 22 ms
8,596 KB
testcase_07 AC 21 ms
8,576 KB
testcase_08 AC 21 ms
8,536 KB
testcase_09 AC 21 ms
8,704 KB
testcase_10 AC 497 ms
10,244 KB
testcase_11 AC 490 ms
10,300 KB
testcase_12 AC 498 ms
10,296 KB
testcase_13 AC 475 ms
10,256 KB
testcase_14 AC 466 ms
10,208 KB
testcase_15 AC 484 ms
10,216 KB
testcase_16 AC 491 ms
10,356 KB
testcase_17 AC 497 ms
10,308 KB
testcase_18 AC 487 ms
10,220 KB
testcase_19 AC 480 ms
10,224 KB
testcase_20 AC 479 ms
10,224 KB
testcase_21 AC 496 ms
10,352 KB
testcase_22 AC 478 ms
10,288 KB
testcase_23 AC 494 ms
10,236 KB
testcase_24 AC 498 ms
10,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
from functools import lru_cache
@lru_cache(maxsize=None)
def calc(a,b,X,k):
    if a==0 and b==0:
        if X==0:
            return 1
        return 0
    ANS=0
    for i in range(10):
        for j in range(10):
            if i<=a and j<=b:
                if i+j+k>=10:
                    ANS+=calc((a-i)//10,(b-j)//10,X-1,1)
                else:
                    ANS+=calc((a-i)//10,(b-j)//10,X,0)
                ANS%=mod
    return ANS
T=int(input())
for tests in range(T):
    N,X=map(int,input().split())
    print(calc(N,N,X,0))
0