結果
問題 | No.605 板挟みの球面 |
ユーザー | Grenache |
提出日時 | 2017-12-10 19:38:02 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 170 ms / 2,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 3,771 ms |
コンパイル使用メモリ | 77,836 KB |
実行使用メモリ | 54,500 KB |
最終ジャッジ日時 | 2024-05-07 16:58:50 |
合計ジャッジ時間 | 4,958 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 166 ms
54,332 KB |
testcase_01 | AC | 170 ms
54,420 KB |
testcase_02 | AC | 170 ms
54,500 KB |
testcase_03 | AC | 166 ms
54,224 KB |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder605 { private static Scanner sc; private static Printer pr; private static void solve() { int n = 1_000_000; double a = sc.nextDouble(); double b = sc.nextDouble(); if (a > b) { double tmp = a; a = b; b = tmp; } double ans = 0; double pre = Math.sqrt(1 - a * a); double d = (b - a) / n; for (int i = 1; i <= n; i++) { double tmp = a + (b - a) * i / n; tmp = Math.sqrt(1 - tmp * tmp); ans += (pre + tmp) / 2 * Math.sqrt(d * d + (tmp - pre) * (tmp - pre)); pre = tmp; } pr.printf("%.7f\n", ans * 2 * Math.PI); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }