結果

問題 No.605 板挟みの球面
ユーザー GrenacheGrenache
提出日時 2017-12-10 19:38:02
言語 Java19
(openjdk 21)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 3,776 ms
コンパイル使用メモリ 74,816 KB
実行使用メモリ 56,296 KB
最終ジャッジ日時 2023-08-20 09:56:40
合計ジャッジ時間 4,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
56,296 KB
testcase_01 AC 157 ms
56,056 KB
testcase_02 AC 157 ms
55,928 KB
testcase_03 AC 160 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
		}
	}
}
0