結果
問題 | No.1632 Sorting Integers (GCD of M) |
ユーザー |
|
提出日時 | 2021-07-30 21:45:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 1,570 bytes |
コンパイル時間 | 181 ms |
コンパイル使用メモリ | 82,092 KB |
実行使用メモリ | 57,748 KB |
最終ジャッジ日時 | 2024-09-21 17:30:34 |
合計ジャッジ時間 | 4,332 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 59 |
ソースコード
import sys,random,bisectfrom collections import deque,defaultdictfrom heapq import heapify,heappop,heappushfrom itertools import permutationsfrom math import gcd,loginput = lambda :sys.stdin.readline().rstrip()mi = lambda :map(int,input().split())li = lambda :list(mi())mod = 10**9 + 7i9 = 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 % modres = 1if any(c[2*i+1] for i in range(0,5)):res *= 1elif c[2] or c[6]:res *= 2elif c[4]:res *= 4else:res *= 8check = 0for i in range(10):check += c[i] * iif check%9==0:res *= 9flag = Truefor i in range(1,10):for j in range(i+1,10):if c[i] and c[j] and (i-j)%3!=0:flag = Falseif flag:check = 0for i in range(1,10):check = check * pow(10,c[i],27) + i * (c[i]*(c[i]-1)//2 * 9 + c[i])check %= 27if check==0:res *= 3elif check%3==0:res *= 3flag = Truefor i in range(1,10):for j in range(i+1,10):if c[i] and c[j] and (i-j)%7!=0:flag = Falseif flag:check = 0for i in range(1,10):check = check * pow(10,c[i],7) + i * (pow(10,c[i],7)-1) * 4check %= 7if check==0:res *= 7return resprint(solve(N,c))#292929