結果

問題 No.443 GCD of Permutation
ユーザー kmjp
提出日時 2016-11-12 00:54:42
言語 Python2
(2.7.18)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 313 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-10-13 23:44:45
合計ジャッジ時間 1,236 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math

def gcd(a, b):
	return a if b == 0 else gcd(b, a%b)

S=raw_input()
num = [0]*10

for c in S:
	num[int(c)]+=1

for i in range(10):
	if num[i] == len(S):
		print S
		sys.exit()

G=0
for y in range(10):
	for x in range(y):
		if num[y] and num[x]:
			G = gcd(G, 9*(y-x))

print gcd(int(S),G)

0