結果

問題 No.2352 Sharpened Knife in Fall
ユーザー Karan AggarwalKaran Aggarwal
提出日時 2023-06-16 23:08:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 3,000 ms
コード長 1,664 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 84,652 KB
実行使用メモリ 4,608 KB
最終ジャッジ日時 2023-09-06 22:01:15
合計ジャッジ時間 11,635 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 215 ms
4,472 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 245 ms
4,604 KB
testcase_07 AC 122 ms
4,384 KB
testcase_08 AC 243 ms
4,476 KB
testcase_09 AC 245 ms
4,480 KB
testcase_10 AC 247 ms
4,604 KB
testcase_11 AC 245 ms
4,608 KB
testcase_12 AC 242 ms
4,480 KB
testcase_13 AC 241 ms
4,608 KB
testcase_14 AC 116 ms
4,380 KB
testcase_15 AC 229 ms
4,488 KB
testcase_16 AC 14 ms
4,380 KB
testcase_17 AC 7 ms
4,384 KB
testcase_18 AC 89 ms
4,384 KB
testcase_19 AC 191 ms
4,488 KB
testcase_20 AC 76 ms
4,392 KB
testcase_21 AC 74 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

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