結果

問題 No.2352 Sharpened Knife in Fall
ユーザー random contestantrandom contestant
提出日時 2023-06-16 22:02:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 780 ms / 3,000 ms
コード長 1,365 bytes
コンパイル時間 4,445 ms
コンパイル使用メモリ 265,364 KB
実行使用メモリ 13,040 KB
最終ジャッジ日時 2023-09-06 19:51:37
合計ジャッジ時間 21,043 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 668 ms
12,936 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 761 ms
12,988 KB
testcase_07 AC 385 ms
8,264 KB
testcase_08 AC 780 ms
12,948 KB
testcase_09 AC 765 ms
12,952 KB
testcase_10 AC 754 ms
12,928 KB
testcase_11 AC 748 ms
12,968 KB
testcase_12 AC 754 ms
12,952 KB
testcase_13 AC 760 ms
13,040 KB
testcase_14 AC 358 ms
8,052 KB
testcase_15 AC 706 ms
12,408 KB
testcase_16 AC 37 ms
4,388 KB
testcase_17 AC 18 ms
4,388 KB
testcase_18 AC 273 ms
6,988 KB
testcase_19 AC 619 ms
10,924 KB
testcase_20 AC 234 ms
6,448 KB
testcase_21 AC 234 ms
6,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行


signed main(){
  double r;
  int k;
  cin >> r >> k;
  // k個の線について二分探索すべきか。
  // 弓型の面積の公式があるのでそれを使う
  auto calc = [&](double x) -> double {
    // y = xの線分の計算
    double h = abs(1 - abs(x)); 
    double theta = 2*acos(1 - h / 1);
    double L = 1 * theta;
    double c = 2 * sqrt(h*(2*1-h));
    double S = theta / 2 - (1 - h)*sqrt(h*(2*1-h));
    return S;
  };
  set<double> ans;
  for(double s = acos(-1) / (k+1); ans.size() != (k)/2; s += acos(-1) / (k+1)){
    double cen = 0;
    double far = 1;
    rep(_,100){
      double mid = (cen + far) / 2;
      if (calc(mid) < s) far = mid;
      else cen = mid;
    }
    ans.insert(cen);
  }
  set<double> realans;
  for(auto x : ans) realans.insert(x);
  for(auto x : ans) realans.insert(-x);
  if (k % 2) realans.insert(0);
  cout << fixed << setprecision(20);
  for(auto x : realans) cout << x * r << endl;
}
0