結果

問題 No.443 GCD of Permutation
ユーザー hiyokko2hiyokko2
提出日時 2016-11-12 00:19:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,115 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 9,636 KB
最終ジャッジ日時 2023-08-16 20:30:45
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 19 ms
8,840 KB
testcase_03 WA -
testcase_04 AC 19 ms
8,748 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 17 ms
8,876 KB
testcase_10 AC 18 ms
8,888 KB
testcase_11 WA -
testcase_12 AC 17 ms
8,680 KB
testcase_13 AC 18 ms
8,932 KB
testcase_14 RE -
testcase_15 AC 96 ms
8,924 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 49 ms
8,896 KB
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 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
A, B = map(int, input().split())
if A + B > A * B:
	print("S")
elif A + B < A * B:
	print("P")
else:
	print("E")
"""
import random



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



#A, B = map(int, input().split())
#print(gcd(A, B))


N = input()
"""
cnt = {}
for c in N:
	if not c in cnt:
		cnt[c] = 1
	else:
		cnt[c] += 1
"""

"""
num = "0123456789"
mn = ""
for n in num:
	if n in cnt:
		for _ in range(cnt[n]):
			mn += n
"""
#print(int(mn))

first = True
for _ in range(1000):
	if first:
		#print("AAA")
		nnn = N
		ans = int(nnn)
		first = False
	else:
		#print("BBB")
		ransu = random.randint(0, len(N)-2)
		if ransu >= 0:
			#print("VCVV")
			#print("N = " + N);
			#print("ransu = " + str(ransu))
			#nn = N[0:ransu-1] + N[ransu+1:ransu+1] + N[ransu:ransu] + N[ransu+2:-1]
			if ransu == 0:
				nn = N[ransu+1] + N[ransu] + N[ransu+2:-1]
			if ransu == 1:
				nn = N[0] + N[ransu+1] + N[ransu] + N[ransu+2:-1]
			else:
				nn = N[0:ransu-1] + N[ransu+1] + N[ransu] + N[ransu+2:-1]
			#print("aaa" + nn + "aaa")
			ans = gcd(ans, int(nn))

print(ans)
0