結果

問題 No.443 GCD of Permutation
ユーザー compass19compass19
提出日時 2016-11-11 23:34:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 10,824 KB
実行使用メモリ 8,580 KB
最終ジャッジ日時 2023-08-16 19:49:03
合計ジャッジ時間 7,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 14 ms
8,332 KB
testcase_02 AC 14 ms
8,300 KB
testcase_03 AC 14 ms
8,224 KB
testcase_04 AC 14 ms
8,304 KB
testcase_05 AC 14 ms
8,208 KB
testcase_06 AC 14 ms
8,220 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 13 ms
8,164 KB
testcase_11 AC 15 ms
8,300 KB
testcase_12 WA -
testcase_13 AC 14 ms
8,288 KB
testcase_14 RE -
testcase_15 WA -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 621 ms
8,580 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def c_number(N):
	n=0
	for i in range(len(N)):
		n+=N[i]*(10**i)
	return n
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
N=list(map(int,list(input())))
if len(N) == 1:
	print(c_number(N)); exit()
if len(N) == 2:
	print(gcd(c_number(N), c_number(N[::-1]))); exit()
n=set(N)
if len(n)==1: print(c_number(N)); exit()
if len(n)==2 and 0 in n:
	print(c_number(sorted(N,reverse=True)));exit()
s=c_number(N)
if s//9 != s/9: print(1); exit()
min_diff=10
for i in n:
	for j in n-{i}:
		if max(i-j,j-i)<min_diff:
			min_diff = max(i-j,j-1)
			s=(i,j)

print((max(i,j)-min(i,j))*9)
0