結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
sotanishy
|
| 提出日時 | 2021-07-30 23:18:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 781 bytes |
| コンパイル時間 | 421 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 52,352 KB |
| 最終ジャッジ日時 | 2024-09-16 03:24:50 |
| 合計ジャッジ時間 | 3,916 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 WA * 23 |
ソースコード
from math import gcd
import sys
input = sys.stdin.readline
def ones(N):
return (pow(10, N, mod) - 1) * pow(9, mod-2, mod) % mod
mod = 10**9 + 7
N = int(input())
c = [0] + list(map(int, input().split()))
for d in range(1, 10):
if c[d] == N:
print(d * ones(N) % mod)
exit()
ans = 0
for i in range(1, 9):
for j in range(i + 1, 10):
if c[i] > 0 and c[j] > 0:
a = 10 * j + i
b = 10 * i + j
d = a - b
ans = gcd(ans, d)
total = sum(d * c[d] for d in range(1, 10))
if total % 3 != 0:
while ans % 3 == 0:
ans //= 3
if total % 9 != 0 and ans % 9 == 0:
ans //= 3
if ans % 5 == 0:
ans //= 5
if any(c[2*i+1] != 0 for i in range(5)):
while ans % 2 == 0:
ans //= 2
print(ans)
sotanishy