結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 21:18:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,153 bytes |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 81,664 KB |
| 実行使用メモリ | 56,064 KB |
| 最終ジャッジ日時 | 2024-09-15 22:37:58 |
| 合計ジャッジ時間 | 5,214 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 52 WA * 7 |
ソースコード
import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import gcd,log
input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())
mod = 10**9 + 7
i9 = pow(9,mod-2,mod)
N = int(input())
c = [0] + li()
def solve(N,c):
for i in range(10):
if c[i]==N:
return i * (pow(10,N,mod)-1) * i9 % mod
res = 1
if any(c[2*i+1] for i in range(0,5)):
res *= 1
elif c[2] or c[6]:
res *= 2
elif c[4]:
res *= 4
else:
res *= 8
check = 0
for i in range(10):
check += c[i] * i
if check%9==0:
res *= 9
elif check%3==0:
res *= 3
flag = True
for i in range(1,10):
for j in range(i+1,10):
if c[i] and c[j] and (i-j)%7:
flag = False
if flag:
check = 0
for i in range(1,10):
check = check * pow(10,c[i],7) + i * (pow(10,c[i],7)-1) * 4
check %= 7
if check==0:
res *= 7
return res
print(solve(N,c))