結果

問題 No.2352 Sharpened Knife in Fall
ユーザー Karan AggarwalKaran Aggarwal
提出日時 2023-06-16 23:08:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 247 ms / 3,000 ms
コード長 1,664 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 86,500 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-24 16:14:06
合計ジャッジ時間 10,834 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

// WEBLINK

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;

using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vii = vector<ii>;
using viii = vector<iii>;

#define pb push_back
#define fst first
#define snd second
#define all(x) (x).begin,(x).end()

template<typename T, typename T1>T amax(T &a, T1 b) {if (b > a)a = b; return a;}
template<typename T, typename T1>T amin(T &a, T1 b) {if (b < a)a = b; return a;}

// ---------- DEBUG --------------------


// #define ON_PC
#ifdef ON_PC
#include </Users/karanaggarwal/code/debug.h>
#else
#define deb(x...)
#endif


///////////////////////////////////

const double pi = 3.14159265358979323846;
const double eps = 1e-10;

double findth(double val)
{
	double l = 0;
	double r = pi;

	while (r - l > eps)
	{
		double m = (l + r) / 2;

		double v = m - sin(m);

		if (v < val - eps) l = m;
		else if (v > val + eps) r = m;
		else return m;
	}
	return l;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	double R;
	int k;

	cin >> R >> k;


	if (k == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	double rt = 1 / (k + 1);

	vector<double> TH;
	for (int rt = 1; rt <= k / 2; rt++)
	{
		double rT = rt; rT /= (k + 1);
		TH.push_back(findth(rT * 2 * pi));
	}

	vector<double> TP;
	for (auto x : TH) TP.push_back(R * cos(x / 2));
	int n = TP.size();
	for (int i = 0; i < n; i++) cout << - TP[i] << endl;
	if (k & 1) cout << 0 << endl;
	for (int i = n - 1; i >= 0; i--) cout << TP[i] << endl;

	return 0;
}
0