結果

問題 No.933 おまわりさんこいつです
ユーザー FromBooska
提出日時 2024-03-12 13:48:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 93,056 KB
最終ジャッジ日時 2024-09-29 22:17:46
合計ジャッジ時間 2,575 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

# たとえば12*23=(10+2)*(20+3)、桁和を求めるということは10は意味がなくなるので(1+2)*(2+3)となる
# つまり各数字の桁和の積でいいはず、式変形

N = int(input())
P = list(map(int, input().split()))

def digitsum(n):
    calc = 0
    for s in str(n):
        calc += int(s)
    return calc

#digitsum(12)

P2 = []
for p in P:
    P2.append(digitsum(p))

#print(P2)

product = 1
for p in P2:
    product *= p
    product = digitsum(product)
#print(product)

current = product
while len(str(current))>1:
    current = digitsum(current)
print(current) 
0