結果

問題 No.2352 Sharpened Knife in Fall
ユーザー tnakao0123tnakao0123
提出日時 2023-06-28 19:28:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 312 ms / 3,000 ms
コード長 970 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 47,436 KB
実行使用メモリ 4,392 KB
最終ジャッジ日時 2023-09-18 23:49:18
合計ジャッジ時間 13,522 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 239 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 311 ms
4,380 KB
testcase_07 AC 156 ms
4,384 KB
testcase_08 AC 312 ms
4,384 KB
testcase_09 AC 311 ms
4,384 KB
testcase_10 AC 310 ms
4,388 KB
testcase_11 AC 310 ms
4,384 KB
testcase_12 AC 311 ms
4,388 KB
testcase_13 AC 311 ms
4,388 KB
testcase_14 AC 145 ms
4,384 KB
testcase_15 AC 291 ms
4,384 KB
testcase_16 AC 17 ms
4,384 KB
testcase_17 AC 8 ms
4,388 KB
testcase_18 AC 112 ms
4,388 KB
testcase_19 AC 244 ms
4,384 KB
testcase_20 AC 96 ms
4,392 KB
testcase_21 AC 92 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2352.cc:  No.2352 Sharpened Knife in Fall - yukicoder
 */

#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_K = 100000;
const double PI = acos(-1.0);
const int CNT = 100;

/* typedef */

/* global variables */

double ls[MAX_K];

/* subroutines */

double area(double r, double th) {
  return r * r * (th - sin(th) * cos(th));
}

double calc(double r, double s) {
  double th0 = 0.0, th1 = PI / 2;
  for (int cnt = 0; cnt < CNT; cnt++) {
    double th = (th0 + th1) / 2;
    if (area(r, th) < s) th0 = th;
    else th1 = th;
  }
  return th0;
}

/* main */

int main() {
  int r, k;
  scanf("%d%d", &r, &k);
  int h = k / 2;

  double s = PI * r * r / (k + 1);

  for (int i = 0; i < h; i++) {
    double th = calc(r, s * (i + 1));
    double li = r * cos(th);
    ls[i] = -li, ls[k - 1 - i] = li;
  }

  for (int i = 0; i < k; i++)
    printf("%.12lf\n", ls[i]);
  
  return 0;
}
0