結果

問題 No.432 占い(Easy)
ユーザー caleicalei
提出日時 2020-01-30 16:23:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 293 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 45,712 KB
最終ジャッジ日時 2023-10-14 08:29:48
合計ジャッジ時間 7,328 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 216 ms
45,416 KB
testcase_01 AC 217 ms
45,372 KB
testcase_02 AC 215 ms
45,536 KB
testcase_03 AC 222 ms
45,288 KB
testcase_04 AC 218 ms
45,324 KB
testcase_05 AC 219 ms
45,492 KB
testcase_06 AC 219 ms
45,408 KB
testcase_07 AC 218 ms
45,520 KB
testcase_08 AC 218 ms
45,480 KB
testcase_09 AC 228 ms
45,712 KB
testcase_10 AC 220 ms
45,332 KB
testcase_11 AC 218 ms
45,360 KB
testcase_12 AC 290 ms
45,480 KB
testcase_13 AC 292 ms
45,324 KB
testcase_14 AC 218 ms
45,504 KB
testcase_15 AC 215 ms
45,336 KB
testcase_16 AC 218 ms
45,352 KB
testcase_17 AC 293 ms
45,464 KB
testcase_18 AC 252 ms
45,516 KB
testcase_19 AC 243 ms
45,524 KB
testcase_20 AC 225 ms
45,436 KB
testcase_21 AC 221 ms
45,412 KB
testcase_22 AC 220 ms
45,504 KB
testcase_23 AC 214 ms
45,516 KB
testcase_24 AC 218 ms
45,688 KB
testcase_25 AC 217 ms
45,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder No.432 占い(Easy) 2020/01/30

from scipy.special import comb

t=int(input())
s=[list(map(int,list(input()))) for _ in range(t)]

for e in s:
    n=len(e)
    res=0
    if n==1:
        print(*e)
    elif n==2:
        res=sum(e)
        if res%9:
            print(res%9)
        else:
            if res==0:
                print(0)
            else:
                print(9)
    else:
        for k,f in enumerate(e,1):
            res+=comb(n-1,k-1,exact=True)*f
        if res==0:
            print(res)
            continue
        ret=(sum(map(int,list(str(res)))))
        if ret%9:
            print(ret%9)
        else:
            print(9)
0