結果

問題 No.432 占い(Easy)
ユーザー calei
提出日時 2020-01-30 16:19:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 58,184 KB
最終ジャッジ日時 2024-09-16 03:37:21
合計ジャッジ時間 26,611 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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:
        print(e[0]+e[1])
    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