結果

問題 No.2193 メガの下1桁
ユーザー shobonvipshobonvip
提出日時 2023-01-13 22:50:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 72,464 KB
最終ジャッジ日時 2023-08-26 04:35:41
合計ジャッジ時間 5,124 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
72,464 KB
testcase_01 AC 80 ms
72,096 KB
testcase_02 AC 81 ms
72,284 KB
testcase_03 AC 90 ms
72,444 KB
testcase_04 AC 86 ms
72,240 KB
testcase_05 AC 84 ms
72,400 KB
testcase_06 AC 83 ms
71,908 KB
testcase_07 AC 83 ms
72,104 KB
testcase_08 AC 83 ms
72,008 KB
testcase_09 AC 83 ms
71,952 KB
testcase_10 AC 82 ms
72,180 KB
testcase_11 AC 82 ms
72,248 KB
testcase_12 AC 82 ms
72,100 KB
testcase_13 AC 77 ms
71,996 KB
testcase_14 AC 78 ms
72,256 KB
testcase_15 AC 77 ms
72,312 KB
testcase_16 AC 78 ms
71,916 KB
testcase_17 AC 83 ms
71,908 KB
testcase_18 WA -
testcase_19 AC 80 ms
71,944 KB
testcase_20 AC 81 ms
72,288 KB
testcase_21 WA -
testcase_22 AC 76 ms
71,932 KB
testcase_23 AC 77 ms
72,452 KB
testcase_24 AC 78 ms
72,180 KB
testcase_25 AC 77 ms
72,204 KB
testcase_26 AC 77 ms
71,892 KB
testcase_27 AC 80 ms
72,148 KB
testcase_28 AC 81 ms
71,948 KB
testcase_29 WA -
testcase_30 AC 78 ms
71,900 KB
testcase_31 WA -
testcase_32 AC 81 ms
72,240 KB
testcase_33 AC 81 ms
72,244 KB
testcase_34 AC 79 ms
72,308 KB
testcase_35 AC 78 ms
72,192 KB
testcase_36 AC 81 ms
72,092 KB
testcase_37 AC 78 ms
72,392 KB
testcase_38 AC 78 ms
72,244 KB
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import random

m = int(input())
d = int(input())
n = int(input())
b = int(input())

def fast(m,d,n,b):
	v = [[0] * b for i in range(60)]
	for i in range(b):
		if (i+d)%b != 0:
			v[0][i] = pow(i+d, i, b)
		else:
			v[0][i] = 0

	for i in range(59):
		for j in range(b):
			v[i+1][j] = v[i][v[i][j]]

	if n == 0:
		r = '0123456789ABCDEFG'
		return r[m % b]

	if m == 0:
		n -= 1
		m = pow(m + d, m, b)

	m %= b
	for i in range(60):
		if (n >> i) & 1:
			m = v[i][m]

	r = '0123456789ABCDEFG'
	return r[m]

def naive(m,d,n,b):
	if n == 0:
		r = '0123456789ABCDEFG'
		return r[m % b]
	if m == 0:
		n -= 1
		m = pow(m+d, m, b)
	m %= b
	for i in range(n):
		if (m+d)%b != 0:
			m = pow(m+d, m, b)
		else:
			m = 0
	
	r = '0123456789ABCDEFG'

	return r[m]

print(fast(m,d,n,b))
0