結果

問題 No.2193 メガの下1桁
ユーザー shobonvipshobonvip
提出日時 2023-01-13 23:03:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 76,724 KB
最終ジャッジ日時 2023-08-26 04:47:59
合計ジャッジ時間 4,958 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
76,548 KB
testcase_01 AC 82 ms
76,336 KB
testcase_02 AC 84 ms
76,472 KB
testcase_03 AC 85 ms
76,564 KB
testcase_04 AC 83 ms
76,536 KB
testcase_05 AC 79 ms
72,028 KB
testcase_06 AC 79 ms
71,980 KB
testcase_07 AC 80 ms
75,900 KB
testcase_08 AC 76 ms
71,876 KB
testcase_09 AC 79 ms
71,984 KB
testcase_10 AC 83 ms
76,636 KB
testcase_11 AC 82 ms
76,232 KB
testcase_12 AC 80 ms
71,960 KB
testcase_13 AC 82 ms
75,940 KB
testcase_14 AC 86 ms
76,564 KB
testcase_15 AC 82 ms
72,140 KB
testcase_16 AC 81 ms
76,724 KB
testcase_17 AC 82 ms
76,024 KB
testcase_18 WA -
testcase_19 AC 79 ms
71,940 KB
testcase_20 AC 79 ms
72,116 KB
testcase_21 WA -
testcase_22 AC 85 ms
76,460 KB
testcase_23 AC 82 ms
71,976 KB
testcase_24 AC 83 ms
75,772 KB
testcase_25 AC 82 ms
71,872 KB
testcase_26 AC 80 ms
75,876 KB
testcase_27 AC 84 ms
76,560 KB
testcase_28 AC 86 ms
76,028 KB
testcase_29 AC 80 ms
75,936 KB
testcase_30 AC 81 ms
76,556 KB
testcase_31 AC 81 ms
75,740 KB
testcase_32 AC 80 ms
72,320 KB
testcase_33 AC 83 ms
76,112 KB
testcase_34 AC 82 ms
76,220 KB
testcase_35 AC 83 ms
76,424 KB
testcase_36 AC 79 ms
72,084 KB
testcase_37 AC 83 ms
75,660 KB
testcase_38 AC 81 ms
71,968 KB
testcase_39 AC 82 ms
76,024 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 = b * euler(b) // gcd(b, euler(b))
		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