結果

問題 No.2193 メガの下1桁
ユーザー shobonvipshobonvip
提出日時 2023-01-13 23:05:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 444 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 87,356 KB
実行使用メモリ 209,072 KB
最終ジャッジ日時 2023-08-26 04:50:05
合計ジャッジ時間 19,646 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 404 ms
208,840 KB
testcase_01 AC 397 ms
208,752 KB
testcase_02 AC 398 ms
208,632 KB
testcase_03 AC 400 ms
208,896 KB
testcase_04 AC 401 ms
208,748 KB
testcase_05 AC 397 ms
208,744 KB
testcase_06 AC 410 ms
209,032 KB
testcase_07 AC 402 ms
208,840 KB
testcase_08 AC 406 ms
208,696 KB
testcase_09 AC 413 ms
208,628 KB
testcase_10 AC 397 ms
208,988 KB
testcase_11 AC 406 ms
208,872 KB
testcase_12 AC 444 ms
209,052 KB
testcase_13 AC 440 ms
208,544 KB
testcase_14 AC 440 ms
208,548 KB
testcase_15 AC 438 ms
208,624 KB
testcase_16 AC 442 ms
208,708 KB
testcase_17 AC 395 ms
208,544 KB
testcase_18 AC 389 ms
208,492 KB
testcase_19 AC 388 ms
208,860 KB
testcase_20 AC 382 ms
208,812 KB
testcase_21 AC 384 ms
208,872 KB
testcase_22 AC 387 ms
208,868 KB
testcase_23 AC 382 ms
208,740 KB
testcase_24 AC 376 ms
208,880 KB
testcase_25 AC 393 ms
208,872 KB
testcase_26 AC 398 ms
209,008 KB
testcase_27 AC 386 ms
208,744 KB
testcase_28 AC 386 ms
208,556 KB
testcase_29 AC 400 ms
208,840 KB
testcase_30 AC 403 ms
208,876 KB
testcase_31 AC 397 ms
208,876 KB
testcase_32 AC 401 ms
208,764 KB
testcase_33 AC 392 ms
209,072 KB
testcase_34 AC 392 ms
208,516 KB
testcase_35 AC 396 ms
209,028 KB
testcase_36 AC 394 ms
208,940 KB
testcase_37 AC 416 ms
208,740 KB
testcase_38 AC 395 ms
208,576 KB
testcase_39 AC 399 ms
208,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
from math import gcd

def pfact(m):
	pf = {}
	for i in range(2,int(m**0.5)+1):
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
	if m>1 : pf[m]=1
	return pf


def euler(m):
	#pfactのdefが必須
	tmp = pfact(m)
	ans = 1
	for i, j in tmp.items():
		ans = ans * (i**(j-1)) * (i-1)
	return ans


while True:
	m = int(input())
	d = int(input())
	n = int(input())
	b = int(input())
	def fast(m,d,n,b):
		nb = 277200
		v = [[0] * nb for i in range(61)]
		for i in range(nb):
			if (i+d)%nb != 0:
				v[0][i] = pow(i+d, i, nb)
			else:
				v[0][i] = 0

		for i in range(60):
			for j in range(nb):
				v[i+1][j] = v[i][v[i][j]]

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

		if m == 0 and d == 0:
			n -= 1
			m = 1

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

		r = '0123456789ABCDEFG'
		return r[m % b]

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