結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー とりゐとりゐ
提出日時 2021-07-04 13:41:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 502 bytes
コンパイル時間 3,758 ms
コンパイル使用メモリ 81,644 KB
実行使用メモリ 53,692 KB
最終ジャッジ日時 2023-10-21 16:14:47
合計ジャッジ時間 5,235 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,692 KB
testcase_01 AC 30 ms
53,692 KB
testcase_02 AC 30 ms
53,628 KB
testcase_03 AC 32 ms
53,692 KB
testcase_04 AC 32 ms
53,692 KB
testcase_05 AC 32 ms
53,692 KB
testcase_06 AC 32 ms
53,692 KB
testcase_07 AC 31 ms
53,692 KB
testcase_08 AC 31 ms
53,692 KB
testcase_09 AC 30 ms
53,692 KB
testcase_10 AC 31 ms
53,692 KB
testcase_11 AC 34 ms
53,692 KB
testcase_12 AC 35 ms
53,692 KB
testcase_13 AC 33 ms
53,692 KB
testcase_14 AC 31 ms
53,692 KB
testcase_15 AC 31 ms
53,692 KB
testcase_16 AC 32 ms
53,692 KB
testcase_17 AC 32 ms
53,692 KB
testcase_18 AC 32 ms
53,692 KB
testcase_19 AC 30 ms
53,692 KB
testcase_20 AC 31 ms
53,692 KB
testcase_21 AC 30 ms
53,692 KB
testcase_22 AC 30 ms
53,692 KB
testcase_23 AC 31 ms
53,692 KB
testcase_24 AC 30 ms
53,692 KB
testcase_25 AC 30 ms
53,692 KB
testcase_26 AC 30 ms
53,692 KB
testcase_27 AC 30 ms
53,692 KB
testcase_28 AC 32 ms
53,692 KB
testcase_29 AC 34 ms
53,692 KB
testcase_30 AC 32 ms
53,692 KB
testcase_31 AC 31 ms
53,692 KB
testcase_32 AC 32 ms
53,692 KB
testcase_33 AC 31 ms
53,692 KB
testcase_34 AC 32 ms
53,692 KB
testcase_35 AC 31 ms
53,692 KB
testcase_36 AC 31 ms
53,692 KB
testcase_37 AC 31 ms
53,692 KB
testcase_38 AC 31 ms
53,692 KB
testcase_39 AC 30 ms
53,692 KB
testcase_40 AC 31 ms
53,692 KB
testcase_41 AC 32 ms
53,692 KB
testcase_42 AC 32 ms
53,692 KB
testcase_43 AC 30 ms
53,692 KB
testcase_44 AC 32 ms
53,692 KB
testcase_45 AC 31 ms
53,692 KB
testcase_46 AC 30 ms
53,692 KB
testcase_47 AC 32 ms
53,692 KB
testcase_48 AC 31 ms
53,692 KB
testcase_49 AC 30 ms
53,692 KB
testcase_50 AC 31 ms
53,692 KB
testcase_51 AC 31 ms
53,692 KB
testcase_52 AC 31 ms
53,692 KB
testcase_53 AC 31 ms
53,692 KB
testcase_54 AC 31 ms
53,692 KB
testcase_55 AC 31 ms
53,692 KB
testcase_56 AC 31 ms
53,692 KB
testcase_57 AC 31 ms
53,692 KB
testcase_58 AC 31 ms
53,692 KB
testcase_59 AC 30 ms
53,628 KB
testcase_60 AC 31 ms
53,628 KB
testcase_61 AC 30 ms
53,628 KB
testcase_62 AC 31 ms
53,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
mod=10**9+7
n=int(input())
c=list(map(int,input().split()))
cnt=[0]*9
for i in range(9):
  if c[i]>0:
    cnt[i]=1
if sum(cnt)==1:
  ans=pow(10,n,mod)-1
  ans*=pow(9,mod-2,mod)
  for i in range(9):
    if cnt[i]==1:
      ans*=i+1
  print(ans%mod)
  exit()
g=0
for i in range(9):
  for j in range(i+1,9):
    if cnt[i]>0 and cnt[j]>0:
      g=math.gcd(g,j-i)
g*=9
m=0
tmp=0
for i in range(9):
  m+=(i+1)*(pow(10,tmp+c[i],g*9)-pow(10,tmp,g*9))
  m%=g*9
  tmp+=c[i]
m//=9
print(math.gcd(m,g))
0