結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー chineristAC
提出日時 2021-07-30 21:34:41
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,182 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 67,200 KB
最終ジャッジ日時 2024-09-15 23:15:17
合計ジャッジ時間 6,430 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 3
other AC * 4 RE * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

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
    assert False

    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!=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
0