結果

問題 No.432 占い(Easy)
ユーザー calei
提出日時 2020-01-30 16:23:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,041 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 58,188 KB
最終ジャッジ日時 2024-09-16 03:37:58
合計ジャッジ時間 27,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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