結果

問題 No.2440 Accuracy of Integer Division Approximate Functions
ユーザー 👑 MizarMizar
提出日時 2023-08-31 12:25:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 231 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 11,580 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2023-08-31 12:25:19
合計ジャッジ時間 6,252 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,244 KB
testcase_01 AC 214 ms
15,152 KB
testcase_02 AC 239 ms
15,352 KB
testcase_03 AC 213 ms
15,220 KB
testcase_04 AC 212 ms
15,456 KB
testcase_05 AC 213 ms
15,284 KB
testcase_06 AC 217 ms
15,224 KB
testcase_07 AC 234 ms
15,256 KB
testcase_08 AC 217 ms
15,384 KB
testcase_09 AC 220 ms
15,248 KB
testcase_10 AC 216 ms
15,348 KB
testcase_11 AC 208 ms
15,408 KB
testcase_12 AC 224 ms
15,344 KB
testcase_13 AC 210 ms
15,248 KB
testcase_14 AC 211 ms
15,260 KB
testcase_15 AC 211 ms
15,096 KB
testcase_16 AC 168 ms
15,220 KB
testcase_17 AC 195 ms
15,488 KB
testcase_18 AC 168 ms
15,220 KB
testcase_19 AC 170 ms
15,360 KB
testcase_20 AC 174 ms
15,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(n,m,a);b=r=0;while n>0;r+=a/m*n*(n-1)/2+b/m*n;a%=m;b%=m;y=a*n+b;n,b,m,a=y/m,y%m,a,m;end;r;end;gets.to_i.times{n,d,m,s=gets.split.map(&:to_i);p,q=1<<s,d*m;if p!=q;n=[n,d*p/(p-q).abs].min;n-=(f(n+1,p,m)-f(n+1,d,1)).abs;end;p n}
0