結果

問題 No.2440 Accuracy of Integer Division Approximate Functions
ユーザー 👑 MizarMizar
提出日時 2023-09-02 03:26:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 245 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 10,484 KB
実行使用メモリ 8,296 KB
最終ジャッジ日時 2023-09-02 03:26:55
合計ジャッジ時間 5,929 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,800 KB
testcase_01 AC 164 ms
8,196 KB
testcase_02 AC 177 ms
8,212 KB
testcase_03 AC 163 ms
8,228 KB
testcase_04 AC 158 ms
8,252 KB
testcase_05 AC 162 ms
8,132 KB
testcase_06 AC 136 ms
8,264 KB
testcase_07 AC 136 ms
8,252 KB
testcase_08 AC 137 ms
8,244 KB
testcase_09 AC 147 ms
8,228 KB
testcase_10 AC 131 ms
8,228 KB
testcase_11 AC 165 ms
8,216 KB
testcase_12 AC 161 ms
8,284 KB
testcase_13 AC 167 ms
8,200 KB
testcase_14 AC 168 ms
8,252 KB
testcase_15 AC 163 ms
8,296 KB
testcase_16 AC 108 ms
8,208 KB
testcase_17 AC 105 ms
8,256 KB
testcase_18 AC 108 ms
8,204 KB
testcase_19 AC 104 ms
8,176 KB
testcase_20 AC 107 ms
8,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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