結果

問題 No.2440 Accuracy of Integer Division Approximate Functions
ユーザー hiro1729hiro1729
提出日時 2023-09-01 18:36:24
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 292 bytes
コンパイル時間 1,259 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-01-03 06:54:18
合計ジャッジ時間 5,589 ms
ジャッジサーバーID
(参考情報)
judge1 / 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());p=1<<s
	if p!=d*m:n=min(n,d*p//abs(d*m-p));n-=abs(f(n+1,p,m,0)-f(n+1,d,1,0))
	print(n)
0