結果
問題 | No.306 さいたま2008 |
ユーザー | YamaKasa |
提出日時 | 2018-09-17 00:27:48 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,752 bytes |
コンパイル時間 | 1,990 ms |
コンパイル使用メモリ | 74,404 KB |
実行使用メモリ | 56,460 KB |
最終ジャッジ日時 | 2023-09-25 09:15:51 |
合計ジャッジ時間 | 6,141 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
55,684 KB |
testcase_01 | AC | 134 ms
55,956 KB |
testcase_02 | AC | 134 ms
55,740 KB |
testcase_03 | AC | 128 ms
56,128 KB |
testcase_04 | AC | 130 ms
56,300 KB |
testcase_05 | AC | 128 ms
55,996 KB |
testcase_06 | AC | 135 ms
56,180 KB |
testcase_07 | AC | 133 ms
56,000 KB |
testcase_08 | AC | 131 ms
56,216 KB |
testcase_09 | AC | 132 ms
55,780 KB |
testcase_10 | AC | 133 ms
55,984 KB |
testcase_11 | AC | 132 ms
56,116 KB |
testcase_12 | AC | 130 ms
56,100 KB |
testcase_13 | AC | 137 ms
56,028 KB |
testcase_14 | AC | 139 ms
56,296 KB |
testcase_15 | AC | 133 ms
55,704 KB |
testcase_16 | AC | 128 ms
56,076 KB |
testcase_17 | AC | 132 ms
56,252 KB |
testcase_18 | AC | 133 ms
56,116 KB |
testcase_19 | AC | 134 ms
55,748 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 130 ms
56,020 KB |
ソースコード
import java.util.Scanner; public class Main { static double xa; static double ya; static double xb; static double yb; public static void main(String[] args) { Scanner scan = new Scanner(System.in); xa = scan.nextDouble(); ya = scan.nextDouble(); xb = scan.nextDouble(); yb = scan.nextDouble(); scan.close(); double yp = 9; double r = Math.max(ya, yb); double l = Math.min(ya, yb); while(Math.abs(r - l) > 0.0000000001) { double y1 = (2.0 * l + r) / 3.0; double y2 = (l + 2.0 * r) / 3.0; // System.out.println(l + " " + r); // System.out.println(y1 + " " + y2); // System.out.println(diff1_func(y1) + " " + diff1_func(y2)); // System.out.println(); // if(Math.abs(diff1_func(y1)) < Math.abs(diff1_func(y2))) { // r = y2; // }else { // l = y1; // } if(func(y1) < func(y2)) { r = y2; }else { l = y1; } } yp = (l + r) / 2.0; System.out.println(yp); System.exit(0); for(int i = 0; i < 100; i++) { double yp_new = yp - diff1_func(yp) / diff2_func(yp); yp = yp_new; System.out.println(yp); } System.out.println(yp); } static double func(double yp) { return Math.pow(func1(yp), 0.5) + Math.pow(func2(yp), 0.5); } static double diff1_func(double yp) { return (yp - ya) * Math.pow(xa * xa + (yp - ya) * (yp - ya), -0.5) + (yp - yb) * Math.pow(xb * xb + (yp - yb) * (yp - yb), -0.5); } static double diff2_func(double yp) { return Math.pow(func1(yp), -0.5) - Math.pow(yp - ya, 2) * Math.pow(func1(yp), -1.5) + Math.pow(func2(yp), -0.5) - Math.pow(yp - yb, 2)* Math.pow(func2(yp), -1.5); } static double func1(double yp) { return xa * xa + (yp - ya) * (yp - ya); } static double func2(double yp) { return xb * xb + (yp - yb) * (yp - yb); } }