結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-30 21:43:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,563 bytes |
| コンパイル時間 | 431 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 57,948 KB |
| 最終ジャッジ日時 | 2024-09-15 23:32:29 |
| 合計ジャッジ時間 | 5,134 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 55 WA * 4 |
ソースコード
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
flag = True
for i in range(1,10):
for j in range(i+1,10):
if c[i] and c[j] and (i-j)%3!=0:
flag = False
if flag:
check = 0
for i in range(1,10):
check = check * pow(10,c[i],27) + i * (c[i]*(c[i]-1)//2 * 9)
check %= 27
if check==0:
res *= 3
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!=0:
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))
#292929