結果
問題 | No.2352 Sharpened Knife in Fall |
ユーザー |
|
提出日時 | 2023-06-19 20:21:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,586 ms / 3,000 ms |
コード長 | 2,361 bytes |
コンパイル時間 | 2,188 ms |
コンパイル使用メモリ | 200,912 KB |
最終ジャッジ日時 | 2025-02-14 23:03:09 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
typedef long long ll;typedef long double ld;#include <bits/stdc++.h>using namespace std;#define int long longll isqrt(ll N){ll sqrtN=sqrt(N)-1;while(sqrtN+1<=N/(sqrtN+1))sqrtN++;return sqrtN;}// Union-Findstruct UnionFind {// core membervector<int> par;// constructorUnionFind() { }UnionFind(int n) : par(n, -1) { }void init(int n) { par.assign(n, -1); }// core methodsint root(int x) {if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool same(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x), y = root(y);if (x == y) return false;if (par[x] > par[y]) swap(x, y); // merge techniquepar[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}// debugfriend ostream& operator << (ostream &s, UnionFind uf) {map<int, vector<int>> groups;for (int i = 0; i < uf.par.size(); ++i) {int r = uf.root(i);groups[r].push_back(i);}for (const auto &it : groups) {s << "group: ";for (auto v : it.second) s << v << " ";s << endl;}return s;}};const double PI=3.14159265358979323846;signed main(){ll r,k;std::cin >> r>>k;// k+1ld R;R=r;for (int i = 0; i < k; i++) {ld target = R*R*PI/ld(k+1)*ld(i+1);ld l,r;l = 0;r = PI;ll cnt = 100;while(cnt){cnt--;ld m = (l+r)/2.0;ld sum;if(m<PI/2.0){sum= PI*R*R*2*m/(2*PI)-R*R*sinl(m)*cosl(m);}else{sum= PI*R*R*2*m/(2*PI)+R*R*sinl(PI-m)*cosl(PI-m);}// std::cout << m<<" "<<sum<<" "<<target << std::endl;if(sum<=target){l = m;}else{r = m;}}if(k%2==1){if(i==k/2){std::cout << 0 << std::endl;continue;}}// std::cout << target<<" "<<l << std::endl;std::cout << setprecision(20)<<-cosl(l)*R << std::endl;}}