結果

問題 No.2352 Sharpened Knife in Fall
ユーザー ks2mks2m
提出日時 2023-06-16 21:47:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 722 ms / 3,000 ms
コード長 1,866 bytes
コンパイル時間 4,124 ms
コンパイル使用メモリ 73,704 KB
実行使用メモリ 62,448 KB
最終ジャッジ日時 2023-09-06 19:16:48
合計ジャッジ時間 20,833 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,448 KB
testcase_01 AC 122 ms
55,752 KB
testcase_02 AC 120 ms
55,764 KB
testcase_03 AC 120 ms
56,308 KB
testcase_04 AC 626 ms
61,572 KB
testcase_05 AC 119 ms
55,748 KB
testcase_06 AC 633 ms
62,372 KB
testcase_07 AC 478 ms
61,384 KB
testcase_08 AC 626 ms
62,448 KB
testcase_09 AC 585 ms
60,580 KB
testcase_10 AC 708 ms
61,368 KB
testcase_11 AC 706 ms
61,272 KB
testcase_12 AC 722 ms
61,184 KB
testcase_13 AC 713 ms
61,284 KB
testcase_14 AC 471 ms
61,208 KB
testcase_15 AC 628 ms
60,828 KB
testcase_16 AC 218 ms
56,716 KB
testcase_17 AC 171 ms
56,016 KB
testcase_18 AC 402 ms
60,696 KB
testcase_19 AC 554 ms
61,068 KB
testcase_20 AC 347 ms
61,440 KB
testcase_21 AC 350 ms
61,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		double p2 = Math.PI * 2;
		double t = Math.PI * r * r;
		if (k % 2 == 1) {
			int num = (k - 1) / 2;
			double[] ans = new double[num];
			double s1 = t / (k + 1) / 2;
			double sum = 0;
			for (int i = 0; i < num; i++) {
				double ok = Math.PI / 2;
				double ng = 0;
				for (int j = 0; j < 100; j++) {
					double mid = (ok + ng) / 2;
					double x = r * Math.cos(mid);
					double y = r * Math.sin(mid);
					double v1 = x * y / 2;
					double v2 = t * mid / p2;
					if (v1 + v2 - sum >= s1) {
						ok = mid;
					} else {
						ng = mid;
					}
				}
				ans[i] = r * Math.sin(ok);
				sum += s1;
			}
			PrintWriter pw = new PrintWriter(System.out);
			for (int i = num - 1; i >= 0; i--) {
				pw.println(-ans[i]);
			}
			pw.println(0);
			for (int i = 0; i < num; i++) {
				pw.println(ans[i]);
			}
			pw.flush();

		} else {
			int num = k / 2;
			double[] ans = new double[num];
			double s1 = t / (k + 1) / 2;
			double s2 = s1 / 2;
			double sum = 0;
			for (int i = 0; i < num; i++) {
				double g = i == 0 ? s2 : s1;
				double ok = Math.PI / 2;
				double ng = 0;
				for (int j = 0; j < 100; j++) {
					double mid = (ok + ng) / 2;
					double x = r * Math.cos(mid);
					double y = r * Math.sin(mid);
					double v1 = x * y / 2;
					double v2 = t * mid / p2;
					if (v1 + v2 - sum >= g) {
						ok = mid;
					} else {
						ng = mid;
					}
				}
				ans[i] = r * Math.sin(ok);
				sum += g;
			}
			PrintWriter pw = new PrintWriter(System.out);
			for (int i = num - 1; i >= 0; i--) {
				pw.println(-ans[i]);
			}
			for (int i = 0; i < num; i++) {
				pw.println(ans[i]);
			}
			pw.flush();
		}
	}
}
0