結果

問題 No.2440 Accuracy of Integer Division Approximate Functions
ユーザー hiro1729
提出日時 2023-09-01 18:37:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-01-03 06:54:30
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(n,m,a,b):
	c=0
	while 1:
		if a>=m:c+=a//m*n*(n-1)//2;a%=m
		if b>=m:c+=b//m*n;b%=m
		y=a*n+b
		if y<m:return c
		n,b,m,a=y//m,y%m,a,m
for _ in range(int(input())):
	n,d,m,s=map(int, input().split())
	if 2**s!=d*m:n=min(n,d*2**s//abs(d*m-2**s));n-=abs(f(n+1,2**s,m,0)-f(n+1,d,1,0))
	print(n)
0