結果
問題 | No.306 さいたま2008 |
ユーザー | lumc_ |
提出日時 | 2018-07-05 08:39:44 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,827 bytes |
コンパイル時間 | 2,441 ms |
コンパイル使用メモリ | 80,268 KB |
実行使用メモリ | 54,636 KB |
最終ジャッジ日時 | 2024-07-01 02:23:29 |
合計ジャッジ時間 | 6,879 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 148 ms
54,324 KB |
testcase_01 | AC | 151 ms
54,328 KB |
testcase_02 | AC | 148 ms
54,536 KB |
testcase_03 | AC | 148 ms
54,432 KB |
testcase_04 | AC | 148 ms
54,532 KB |
testcase_05 | AC | 150 ms
54,392 KB |
testcase_06 | AC | 151 ms
54,392 KB |
testcase_07 | AC | 149 ms
54,368 KB |
testcase_08 | AC | 151 ms
54,376 KB |
testcase_09 | AC | 152 ms
54,396 KB |
testcase_10 | AC | 153 ms
54,472 KB |
testcase_11 | AC | 151 ms
54,396 KB |
testcase_12 | AC | 153 ms
54,180 KB |
testcase_13 | AC | 153 ms
54,404 KB |
testcase_14 | AC | 152 ms
54,432 KB |
testcase_15 | AC | 152 ms
54,560 KB |
testcase_16 | AC | 150 ms
54,412 KB |
testcase_17 | AC | 152 ms
54,460 KB |
testcase_18 | AC | 152 ms
54,636 KB |
testcase_19 | AC | 150 ms
54,440 KB |
testcase_20 | WA | - |
testcase_21 | AC | 149 ms
54,636 KB |
testcase_22 | AC | 156 ms
54,364 KB |
ソースコード
import java.util.Scanner; import java.util.function.DoubleUnaryOperator; import java.lang.Math; /** * @Problems https://yukicoder.me/problems/no/306 */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double x1 = sc.nextDouble(), y1 = sc.nextDouble(), x2 = sc.nextDouble(), y2 = sc.nextDouble(); Sanbun s = new Sanbun(0, 1000); s.setFunction(y -> { double sa1 = Math.abs(y - y1); double sa2 = Math.abs(y - y2); return Math.sqrt(x1*x1+sa1*sa1)+Math.sqrt(x2*x2+sa2*sa2); }); System.out.println(s.run(100)); } } class Sanbun { private double left, right; private DoubleUnaryOperator function; private double gosa = 0.00000001; public Sanbun(double left, double right) { this.left = left; this.right = right; } public Sanbun(double left, double right, DoubleUnaryOperator function) { this(left, right); this.function = function; } private double calc(double value) { return function.applyAsDouble(value); } public void setFunction(DoubleUnaryOperator function) { this.function = function; } public double run(int x) { for(int i = 0; i < x; i++) { double midLeft = left + (right - left) / 3; double midRight = right - (right - left) / 3; double midLeftResult = calc(midLeft); double midRightResult = calc(midRight); if (midLeftResult == midRightResult) { left = midLeft; right = midRight; } else if (midLeftResult > midRightResult) { left = midLeft; } else { right = midRight; } } return left; } }