結果

問題 No.1819 Mirrored 2
ユーザー titia
提出日時 2022-01-22 00:05:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-26 07:05:04
合計ジャッジ時間 2,349 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23 WA * 2 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

P,Q,x,y=map(int,input().split())

# N mod P = x

N=y

REV=int(str(N)[::-1])


kk=pow(REV,P-2,P)*x%P

# 10**y == kk

# modが素数の場合

import math
a = 10
b = kk

mod = P

SQ = int(math.sqrt(mod))+1
Powdict = {pow(a,i,mod):i for i in range(SQ)} # Baby-Step

A = pow(pow(a,mod-2,mod),SQ,mod)

for i in range(SQ): # Giant-Step
    if b*pow(A,i,mod)%mod in Powdict:
        ANS = i*SQ+Powdict[b*pow(A,i,mod)%mod]
        break

print(str(REV)+"0"*ANS)


0