結果

問題 No.2558 中国剰余定理
ユーザー ch1channnch1channn
提出日時 2023-12-02 14:40:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 845 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 53,716 KB
最終ジャッジ日時 2023-12-02 14:40:28
合計ジャッジ時間 2,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,716 KB
testcase_01 AC 35 ms
53,716 KB
testcase_02 AC 35 ms
53,716 KB
testcase_03 AC 34 ms
53,716 KB
testcase_04 AC 37 ms
53,716 KB
testcase_05 AC 33 ms
53,716 KB
testcase_06 AC 32 ms
53,716 KB
testcase_07 AC 33 ms
53,716 KB
testcase_08 AC 34 ms
53,716 KB
testcase_09 AC 33 ms
53,716 KB
testcase_10 AC 35 ms
53,716 KB
testcase_11 AC 32 ms
53,716 KB
testcase_12 AC 34 ms
53,716 KB
testcase_13 AC 33 ms
53,716 KB
testcase_14 AC 34 ms
53,716 KB
testcase_15 AC 32 ms
53,716 KB
testcase_16 AC 32 ms
53,716 KB
testcase_17 AC 33 ms
53,716 KB
testcase_18 AC 32 ms
53,716 KB
testcase_19 AC 33 ms
53,716 KB
testcase_20 AC 33 ms
53,716 KB
testcase_21 AC 32 ms
53,716 KB
testcase_22 AC 34 ms
53,716 KB
testcase_23 AC 35 ms
53,716 KB
testcase_24 AC 32 ms
53,716 KB
testcase_25 AC 34 ms
53,716 KB
testcase_26 AC 33 ms
53,716 KB
testcase_27 AC 33 ms
53,716 KB
testcase_28 AC 35 ms
53,716 KB
testcase_29 AC 33 ms
53,716 KB
testcase_30 AC 33 ms
53,716 KB
testcase_31 AC 33 ms
53,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
if sys.platform =='ios':
	import clipboard
	a=clipboard.get()
	a = a.split('\n')
	text = '\n'.join(a)
	with open('input_file.txt','w') as f:
		f.write(text)
	sys.stdin = open('input_file.txt')
sys.setrecursionlimit(410000000)
stdin = sys.stdin 
def ni():return int(ns())
def na():return list(map(int, stdin.readline().split()))
def ns():return stdin.readline().strip()
def nm():return map(int,input().split())
def na_1():return list(map(lambda x:int(x)*(-1), stdin.readline().split()))
def na_2():return list(map(lambda x:int(x)-1, stdin.readline().split()))
rnage=range
rnge=range
rage = range


def mod_inv(a,m):
	m0,x0,x1 = m,0,1
	while a > 1:
		q = a//m
		m,a = a%m,m
		x0,x1 = x1-q*x0,x0
	return x1+m0 if x1 < 0 else x1
from math import *
A,B,a,b = nm()
g = gcd(A,B)

lcm = A*B//g

x = (a+A*mod_inv(A//g,B//g)*(b-a))%lcm
print(x)
0