text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const double PI = atan(1) * 4.0; string s; void solve() { long double n; cin >> n; long double angel = 45.0 / n; long double perpen = 1.0 / tan(angel * PI / 180.0); long double side = 1 / (2 * sin((angel)*PI / 180.0)); cout << fixed << setprecision(16); cout << (side) << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) solve(); }
#include <bits/stdc++.h> using namespace std; void solve() { long double n; long double pi = 2 * acos(0); cin >> n; cout << fixed << setprecision(8); cout << cos(pi / (4 * n)) / sin(pi / (2 * n)) << "\n"; } int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cerr.tie(0); ; int t; t = 1; cin >> t; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int t; double n; int main() { cin >> t; while (t--) { cin >> n; int dx = n / 2; double ans = 1 / sin(acos(-1) / (2 * n)) / 2; double t1 = sin(dx * acos(-1) / n / 2) * ans * sqrt(2); double t2 = sin((dx + 1) * acos(-1) / n / 2) * ans * sqrt(2); printf("%.9f\n", t1 + t2); } return 0; }
#include <bits/stdc++.h> using namespace std; const double pi = 3.14159265358979323846264338327950288419716939937510; void solve() { int n; cin >> n; int k = (n - 1) / 2; double d = 1 / sin(pi / (4 * k + 2)); double a = sqrt(2) * sin((pi * k) / (4 * k + 2)) * d; assert(a * a <= 2 * d * d); cout << setprecision(30) << (a + sqrt(2 * d * d - a * a)) / 2; cout << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> template <typename T> std::ostream &operator<<(std::ostream &os, std::vector<T> v) { os << "["; for (int i = 0; i < int((v).size()); i++) os << v[i] << " "; return os << "]"; } using namespace std; long long INF = (1ll << 61); long double EPS = 1e-12; long double PI = acos(-1.0); struct pt { long double x, y; pt() {} pt(long double x, long double y) : x(x), y(y) {} pt(const pt &p) : x(p.x), y(p.y) {} pt operator+(const pt &p) const { return pt(x + p.x, y + p.y); } pt operator-(const pt &p) const { return pt(x - p.x, y - p.y); } pt operator*(long double c) const { return pt(x * c, y * c); } pt operator/(long double c) const { return pt(x / c, y / c); } long double norm() { return sqrt(x * x + y * y); } bool operator==(const pt &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } bool operator<(pt &p) { return tie(x, y) < tie(p.x, p.y); } }; long double dot(pt p, pt q) { return p.x * q.x + p.y * q.y; } long double dist2(pt p, pt q) { return dot(p - q, p - q); } long double cross(pt p, pt q) { return p.x * q.y - p.y * q.x; } ostream &operator<<(ostream &os, const pt &p) { return os << "(" << p.x << "," << p.y << ")"; } pt RotateCCW(pt p, long double t) { return pt(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t)); } bool PointInConvexPol(vector<pt> &l, pt p) { auto vec = [](pt a, pt b) { return a.x * b.y - a.y * b.x; }; int a = 1, b = int((l).size()) - 1, c; if (vec(l[a] - l[0], l[b] - l[0]) > 0) swap(a, b); if (vec(l[a] - l[0], p - l[0]) > 0 || vec(l[b] - l[0], p - l[b]) < 0) return 0; while (abs(a - b) > 1) { c = (a + b) / 2; if (vec(l[c] - l[0], p - l[0]) > 0) b = c; else a = c; } return vec(l[b] - l[a], p - l[a]) <= 0; } vector<pt> getkgon(int k, long double m) { long double phi = (2 * PI) / k; vector<pt> res; pt p = {m, 0}; for (int i = 0; i < k; i++) { res.push_back(RotateCCW(p, -i * phi)); } return res; } bool check(long double m, vector<pt> &poly) { vector<pt> sq = getkgon(4, m); for (auto &k : poly) { if (!PointInConvexPol(sq, k)) return 0; } return 1; } int main(int argc, char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int test_casesq; cin >> test_casesq; for (int tt = 0; tt < test_casesq; tt++) { int n; cin >> n; n *= 2; long double alpha = (n - 2) * PI / (2 * n); long double x = (1 / 2.0) / cos(alpha); vector<pt> poly = getkgon(n, x); long double i = 0, j = 1e7; while (j - i > 1e-12) { long double m = i + (j - i) / 2; if (check(m, poly)) { j = m; } else { i = m; } } cout << fixed << setprecision(14) << 2 / sqrt(2) * i << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; int n; double edge; while (t) { cin >> n; n = n * 2; edge = sin(3.1415926535897932384626 / n / 2); edge = 0.5 / edge; cout << setprecision(12); cout << edge << endl; --t; } return 0; }
#include <bits/stdc++.h> using namespace std; bool desc(int a, int b) { return (a > b); } bool pairone(pair<int, int> &a, pair<int, int> &b) { return (a.first < b.first); } void show(vector<int> vec) { for (auto x : vec) cout << x << " "; cout << endl; ; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; int t; cin >> t; while (t--) { int n; cin >> n; double sides = 2 * n; double side1 = 0; double theta0 = (180.0 * (sides - 2)) / (sides); double theta = 90 - theta0 / 2.0; int even = n / 2; int odd = n / 2 + 1; if (even % 2 == 1) swap(odd, even); int i; for (i = 0; i < even / 2; i++) { side1 += cos(theta * 3.14159265 / 180.00); theta = (180.0 - theta0 + theta); } side1 *= 2; side1 /= sqrt(2); theta = 180.0 - theta0; double side2 = 0; for (i = 0; i < (odd - 1) / 2; i++) { side2 += cos(theta * 3.14159265 / 180.0); theta = (180.0 + theta - theta0); } side2 += 0.5; side2 *= 2; side2 /= sqrt(2); double side = side1 + side2; cout << setprecision(15) << side << endl; } }
#include <bits/stdc++.h> using namespace std; double PI = acos(-1.0); long long mod = 1e9 + 7; const long long inf = 92233720368547758; long long T = 1; vector<vector<long long> > v; long long n, m, x, y, k; vector<long long> dp, vis, depth; string s; long long ceil_(long long x, long long y) { if (x % y == 0) return x / y; return (x / y) + 1; } long long floor_(long long x, long long y) { return x / y; } bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long fpow(long long a, long long b) { return b ? fpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; } long long power(float x, int y) { float temp; if (y == 0) return 1; temp = power(x, y / 2); if (y % 2 == 0) return temp * temp; else { if (y > 0) return x * temp * temp; else return (temp * temp) / x; } } string lower(string s) { for (int i = 0; i < s.length(); i++) s[i] = tolower(s[i]); return s; } long long inv(long long i) { if (i == 1) return 1; return (mod - (mod / i) * inv(mod % i) % mod) % mod; } void show_tree() { for (int i = 1; i <= n; i++) { for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << " "; cout << "\n"; } } void dfs(int i) { vis[i] = 1; for (auto u : v[i]) { if (!vis[u]) dfs(u); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> T; while (T--) { cin >> n; cout << fixed << setprecision(7) << cos(PI / (4 * n)) / sin(PI / (2 * n)) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; void sol() { double pi = 2 * acos(0.0); double n; cin >> n; n *= 2.0; double ang = 360.0 / n; double ans1 = cos(ang / 4.0 * pi / 180.0); double ans2 = sin(ang / 2.0 * pi / 180.0); ans1 /= ans2; printf("%f\n", ans1); } int main() { int t; cin >> t; while (t > 0) { t--; sol(); } return 0; }
#include <bits/stdc++.h> using namespace std; int64_t binexp(int64_t base, int64_t exponent) { int64_t res = 1; base = (base + 1000000007) % 1000000007; while (exponent) { if (exponent & 1) { res = (res * base) % 1000000007; } exponent = exponent >> 1; base = (base * base) % 1000000007; } return res; } void solve() { double n; cin >> n; n = 2.0 * n; double param, result; param = (3.14159265 / n); result = sin(param); double ans1 = (1.0 / (result)); double res = cos(param / 2.0); double ans2 = (1.0 * res); double ans = (ans1 * ans2); printf("%.10f\n", ans); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int T = 1; cin >> T; while (T--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; n *= 2; long double alpha = 180.0 / n; long double r = 1.0 / (2.0 * sin(alpha * 3.14159265 / 180.0)); long double cosres = cos(0.5 * alpha * 3.14159265 / 180.0); long double res = r * cosres * 2; cout << setprecision(12) << res << endl; } int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) solve(); }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long dot(complex<long long> c1, complex<long long> c2) { return imag(c1 * conj(c2)); } double dot(complex<double> c1, complex<double> c2) { return imag(c1 * conj(c2)); } long long point(complex<long long> c1, complex<long long> c2) { return real(c1 * conj(c2)); } double point(complex<double> c1, complex<double> c2) { return real(c1 * conj(c2)); } void solve() { long double n, pi2, alpha, r, res; pi2 = acos(0.0); cin >> n; alpha = pi2 / n; r = 1.0 / sin(alpha); res = r * cos(alpha * 0.5); cout << res << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t, cases; cin >> cases; cout << fixed << setprecision(10); for (t = 0; t < cases; t++) { solve(); } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { double n, r; cin >> n; r = cos(3.141592653589793238462643383279502884197169399375105820974944592307816406286 * (1 / (4 * n))) / sin(3.141592653589793238462643383279502884197169399375105820974944592307816406286 * (1 / (2 * n))); cout << fixed << setprecision(6) << r << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; void display(vector<int> &a) { for (int z : a) cout << z << " "; cout << endl; } int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; const int mod = (int)1e9 + 7; const long long INF64 = 3e18; void smxl(long long &a, long long b) { if (a < b) a = b; } void smnl(long long &a, long long b) { if (a > b) a = b; } void adsl(long long &a, long long b) { a += b; if (a >= mod) a -= mod; } void misl(long long &a, long long b) { a -= b; if (a >= mod) a -= mod; if (a < 0) a += mod; } void smx(long long &a, long long b) { if (a < b) a = b; } void smn(long long &a, long long b) { if (a > b) a = b; } void ads(long long &a, long long b) { a += b; if (a >= mod) a -= mod; } void mis(long long &a, long long b) { a -= b; if (a >= mod) a -= mod; if (a < 0) a += mod; } long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); } long long egcd(long long a, long long b, long long &x, long long &y) { if (a == 0) { x = 0; y = 1; return b; } long long x1, y1; long long d = egcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d; } long long mbinp(long long a, long long b) { a %= mod; if (b == 0) return 1; long long ans = mbinp(a, b / 2); long long tmp = (ans * ans) % mod; if (b % 2) return ((tmp * a) % mod); return ((tmp) % mod); } long long binp(long long a, long long b) { if (b == 0) return 1; long long ans = binp(a, b / 2); long long tmp = (ans * ans); if (b % 2) return ((tmp * a)); return ((tmp)); } long long C(int n, int m) { long long ret = 1; for (int i = 1; i <= m; i++) { ret *= (n - i + 1); ret /= i; } return ret; } long long overbinp(long long a, int b) { long long res = 1; while (b) { if (b & 1) { if (res < INF64 / a) res *= a; else return INF64; } if (b > 1) { if (a < INF64 / a) a *= a; else return INF64; } b >>= 1; } return res; } class BinaryLift { vector<vector<int> > binlift; int n; public: BinaryLift(vector<int> rnk, vector<int> par) { n = (int)par.size(); binlift.resize(n); for (int i = 0; i < n; i++) binlift[i].resize(20); for (int i = 0; i < n; i++) binlift[i][0] = par[i]; for (int j = 1; j < 20; j++) for (int i = 0; i < n; i++) { if ((1 << j) < rnk[i]) binlift[i][j] = binlift[binlift[i][j - 1]][j - 1]; else binlift[i][j] = -1; } } public: int get_kth_ancestor(int x, int k) { int pt = x; for (int i = 19; i >= 0; i--) { if (pt == -1) exit(0); if (k & (1 << i)) pt = binlift[pt][i]; } return pt; } public: int get_th_ancestor(int x, int k) { int pt = x; for (int i = 19; i >= 0; i--) { if (k & (1 << i)) pt = binlift[pt][i]; } return pt; } }; class SparseTable2D { vector<vector<vector<vector<int> > > > sparse; vector<vector<int> > inp; int m, n; private: int lg2(int x) { int out = 0; while ((1 << out) <= x) out++; return out - 1; } public: int rmin(int x1, int y1, int x2, int y2) { int lenx = x2 - x1 + 1; int lx = lg2(lenx) + 1; int leny = y2 - y1 + 1; int ly = lg2(leny) + 1; return min( min(sparse[lx][x1][ly][y1], sparse[lx][x1][ly][y2 + 1 - (1 << ly)]), min(sparse[lx][x2 + 1 - (1 << lx)][ly][y1], sparse[lx][x2 + 1 - (1 << lx)][ly][y2 + 1 - (1 << ly)])); } public: SparseTable2D(vector<vector<int> > input, string param) { n = input.size(); m = input[0].size(); inp = input; if (param == "min") prepromin(); } private: void prepromin() { int lln, lm; lln = lg2(n) + 1; lm = lg2(m) + 1; sparse.resize(lln); for (int i = 0; i < lln; i++) sparse[i].resize(n); for (int i = 0; i < lln; i++) for (int j = 0; j < n; j++) sparse[i][j].resize(lm); for (int i = 0; i < lln; i++) for (int j = 0; j < n; j++) for (int k = 0; k < lm; k++) sparse[i][j][k].resize(m); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) sparse[0][i][0][j] = inp[i][j]; for (int j = 1; j < lm; j++) for (int k = 0; k + (1 << j) - 1 < m; k++) sparse[0][i][j][k] = min(sparse[0][i][j - 1][k], sparse[0][i][j - 1][k + (1 << (j - 1))]); } for (int i = 1; i < lln; i++) for (int j = 0; j + (1 << i) - 1 < n; j++) for (int k = 0; k < lm; k++) for (int h = 0; h < m; h++) sparse[i][j][k][h] = min(sparse[i - 1][j][k][h], sparse[i - 1][j + (1 << (i - 1))][k][h]); } }; class SparseTable { vector<vector<long long> > sparse; int n; vector<int> input; private: int lg2(int x) { int out = 0; while ((1 << out) <= x) out++; return out - 1; } public: int rmaxpos(int left, int right) { int len = right - left + 1; int lg = lg2(len); return (input[sparse[left][lg]] > input[sparse[left + len - (1 << lg)][lg]] ? sparse[left][lg] : sparse[left + len - (1 << lg)][lg]); } public: int rmaxval(int left, int right) { int len = right - left + 1; int lg = lg2(len); return (input[sparse[left][lg]] > input[sparse[left + len - (1 << lg)][lg]] ? input[sparse[left][lg]] : input[sparse[left + len - (1 << lg)][lg]]); } public: int rminpos(int left, int right) { int len = right - left + 1; int lg = lg2(len); return (input[sparse[left][lg]] < input[sparse[left + len - (1 << lg)][lg]] ? sparse[left][lg] : sparse[left + len - (1 << lg)][lg]); } public: int rminval(int left, int right) { int len = right - left + 1; int lg = lg2(len); return (input[sparse[left][lg]] < input[sparse[left + len - (1 << lg)][lg]] ? input[sparse[left][lg]] : input[sparse[left + len - (1 << lg)][lg]]); } public: long long rsum(int left, int right) { long long ans = 0; int pos; while (left <= right) { for (int i = 19; i >= 0; i--) if ((1 << i) <= right - left + 1) { pos = i; break; } ans += sparse[left][pos]; left = left + (1 << pos); } return ans; } public: SparseTable(vector<int> inp, string operation) { input = inp; n = inp.size(); if (operation == "min") prepromin(); else if (operation == "max") prepromax(); else if (operation == "sum") preprosum(); } private: void prepromin() { sparse.resize(n); int x = lg2(n) + 1; for (int i = 0; i < n; i++) sparse[i].resize(x); for (int i = 0; i < n; i++) sparse[i][0] = i; for (int j = 1; j < x; j++) for (int i = 0; i + (1 << (j)) - 1 < n; i++) sparse[i][j] = (input[sparse[i][j - 1]] < input[sparse[i + (1 << (j - 1))][j - 1]] ? sparse[i][j - 1] : sparse[i + (1 << (j - 1))][j - 1]); } void prepromax() { sparse.resize(n); int x = lg2(n) + 1; for (int i = 0; i < n; i++) sparse[i].resize(x); for (int i = 0; i < n; i++) sparse[i][0] = i; for (int j = 1; j < x; j++) for (int i = 0; i + (1 << (j)) - 1 < n; i++) sparse[i][j] = (input[sparse[i][j - 1]] > input[sparse[i + (1 << (j - 1))][j - 1]] ? sparse[i][j - 1] : sparse[i + (1 << (j - 1))][j - 1]); } void preprosum() { sparse.resize(n); int x = lg2(n) + 1; for (int i = 0; i < n; i++) sparse[i].resize(x); for (int i = 0; i < n; i++) sparse[i][0] = input[i]; for (int j = 1; j < x; j++) for (int i = 0; i + (1 << (j)) - 1 < n; i++) sparse[i][j] = sparse[i][j - 1] + sparse[i + (1 << (j - 1))][j - 1]; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; if (n % 2) cout << fixed << setprecision(7) << cos(acos(-1) / (4 * n)) / sin(acos(-1) / (2 * n)) << '\n'; else cout << fixed << setprecision(7) << cos(acos(-1) / (2 * n)) / sin(acos(-1) / (2 * n)) << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { double n; cin >> n; n = 2 * n; double deg = 2 * acos(0.0) / n; double ans = cos(deg / 2) / sin(deg); cout << fixed << setprecision(9) << ans << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { double n; cin >> n; double up = cos(3.14159265358979323846 / (4.0 * n)); double down = sin(3.14159265358979323846 / (2.0 * n)); double ans = up / down; cout << setprecision(10) << ans << endl; } }
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); int t, n; signed main() { cin >> t; while (t--) { cin >> n; if (n == 2) { printf("1.000000000\n"); } else { double p = (n * 2 - 2) * pi / n / 2, minus = (pi - p) / 2.0, tmp = 1; int tt; if (n & 1) tt = n / 2; else tt = n / 2 - 1; for (int i = 1; i < tt; ++i) tmp = sqrt(1 + tmp * tmp - 2 * tmp * cos(p)), p -= minus; if (n & 1) tmp += sqrt(1 + tmp * tmp - 2 * tmp * cos(p)); else tmp *= 2; printf("%.9lf\n", tmp / sqrt(2.0) + (n % 2 == 0)); } } return 0; }
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323846264338327; pair<double, double> f(int N, double ang) { double L = 0, R = 0, H = 0; double x = 0, y = 0; for (int i = 0; i < 2 * N; i++) { x += cos(ang + PI * i / N); y += sin(ang + PI * i / N); R = max(R, x); L = min(L, x); H = max(H, y); } return {R - L, H}; } int main() { int T; scanf("%d", &T); while (T--) { int N; scanf("%d", &N); double l = 0, r = PI / N / 2; while (abs(r - l) > 0.0000001) { double mid = (l + r) / 2; auto res = f(N, mid); if (res.second < res.first) l = mid; else r = mid; } printf("%.15lf\n", f(N, l).first); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); if (n % 2 == 0) { double h = 1.0 / tan(3.14159265358979323846264338327950288 / (2 * n)); printf("%.17g\n", h); } else { double alpha = 3.14159265358979323846264338327950288 / n; double beta = (3.14159265358979323846264338327950288 / 2 - (n / 2) * alpha) / 2; double a = 1 / (2 * sin(alpha / 2)); double h = 2 * a * cos(beta); printf("%.17g\n", h); } } }
#include <bits/stdc++.h> using namespace std; mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 2e5 + 10; const double pi = acos(-1); int main() { int cas; cin >> cas; double n; while (cas--) { cin >> n; printf("%.10lf\n", cos(pi / 4.0 / n) / sin(pi / 2.0 / n)); } return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const int N = 2000005; const double PI = 4 * atan(1); const double eps = 1e-7; const long long oo = 1e10; const int K = 205; long long t; long double angle, angle2; long double val; long double a, b; long double l, r; long double m1, m2; long long n; void fun(long double phi) { long double ansx1 = 0.0; long double ansx2 = 0.0; long double ansy1 = 0.0; long double ansy2 = 0.0; for (int i = 0; i < n; i++) { ansx1 = (ansx1 > b * cos(i * angle + phi) ? ansx1 : b * cos(i * angle + phi)); ansx2 = (ansx2 < b * cos(i * angle + phi) ? ansx2 : b * cos(i * angle + phi)); ansy1 = (ansy1 > b * sin(i * angle + phi) ? ansy1 : b * sin(i * angle + phi)); ansy2 = (ansy2 < b * sin(i * angle + phi) ? ansy2 : b * sin(i * angle + phi)); } val = (ansx1 - ansx2 > ansy1 - ansy2 ? ansx1 - ansx2 : ansy1 - ansy2); } int main() { cin >> t; while (t--) { scanf("%lld", &n); n *= 2; angle = 2 * PI / (long double)(1.0 * n); b = 0.5 / sin(angle / 2); l = 0; r = 2 * PI / n; for (int i = 0; i < 100; i++) { m1 = l + (r - l) / 3; m2 = r - (r - l) / 3; val = 0; fun(m1); long double f1 = val; val = 0; fun(m2); long double f2 = val; if (f1 > f2) l = m1; else r = m2; } val = 0; fun(l); a = val; printf("%0.8Lf\n", a); } return 0; }
#include <bits/stdc++.h> using namespace std; bool comp(int i, int j) { return (i < j); } long long err(long long x, long long y, long long z) { return (((x - y) / 2) * ((x - y) / 2) + ((x - z) / 2) * ((x - z) / 2) + ((y - z) / 2) * ((y - z) / 2)); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); double f, g, e1, e2, pi; long long bb, cc, dd, i, j, maxx, a0, rrr, minn, ans_l, ans_r, min_sum, min_pos, sum, sum1, sum2, sum3, sum4, sum5, k1, k2, kk1, kk2; long long y, x, u, h, a1, aa, k, n, t, ch, zz = 0, kl, odn = 1, m, m1, m2, m0, m3, m4, xl, xr, yl, yr, i1, i2, a2, i3, nn, x1, x2, y1, y2, z11, z1, z2, z3, z4; int l, r; string s, s1, s2; set<long long> nk; l = 0; h = 0; pi = atan(1) * 4; ch = 0; bb = 0; aa = 0; a0 = 0; zz = 20000000000; k = 0; r = 0; t = 0; j = 0; zz = 0; k1 = 0; k2 = 0; kk1 = 0; kk2 = 0; m1 = 0; m2 = 0; m3 = 0; m4 = 0; sum = 0; cin >> t; for (kk2 = 0; kk2 < t; kk2++) { cin >> n; { e1 = 1.0 / (2 * sin(pi / (2 * n))); e1 = e1 * 2; } ch = n / 2; e1 = e1 * sin(pi / 4 + ch * pi / (2 * n)); printf("%10.10f\n", e1); } return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); int n; int main() { int T; cin >> T; while (T--) { cin >> n; double theta1 = PI / n, x = 0.5 / sin(0.5 * theta1), theta2 = PI / n * round(n / 4.0); printf("%.9lf\n", x / sin(PI / 4) * sin(theta2) + x / sin(PI / 4) * sin(PI / 2 - theta2)); } return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2>& a) { in >> a.first >> a.second; return in; } template <typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> a) { out << a.first << " " << a.second; return out; } 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; } const long long INF = 1e18; const int32_t M = 1e9 + 7; const int32_t MM = 998244353; double pi = 3.141592653589793238; void solve() { long long n; cin >> n; cout << setprecision(12) << fixed; if (n % 2 == 0) { double ans = 1 / tan(pi / (2 * n)); cout << ans << "\n"; } else { double ans = cos(pi / (4 * n)) / sin(pi / (2 * n)); cout << ans << "\n"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1; cin >> t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; long long int mypow(long long int a, long long int b) { long long int res = 1; while (b) { if (b & 1) res = res * a; b >>= 1; if (b) { a = a * a; } } return res; } long long int modpow(long long int a, long long int b, long long int m = 1000000007) { a %= m; long long int res = 1; while (b) { if (b & 1) res = res * a % m; b >>= 1; if (b) { a = a * a % m; } } return res; } long long int modinv(long long int a) { return modpow(a, 1000000007 - 2, 1000000007); } vector<long long int> power(11); void initl() { vector<int> p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31}; for (int(i) = (0); (i) < (p.size()); ++(i)) { power[i] = modpow(2, p[i]) - 1; } } bool mycompr(pair<int, int> i1, pair<int, int> i2) { return i1.second > i2.second; } void bfs(int root, int par, vector<bool> &vis, vector<long long int> &dist, vector<vector<int> > &adj) { queue<int> q; q.push(root); dist[root] = 0; vis[root] = true; while (!q.empty()) { int p = q.front(); q.pop(); for (int i = 0; i < adj[p].size(); i++) { if (vis[adj[p][i]] == false) { dist[adj[p][i]] = dist[p] + 1; q.push(adj[p][i]); vis[adj[p][i]] = true; } } } } void graph(vector<vector<int> > &adj, int m) { int x, y; for (int(i) = (0); (i) < (m); ++(i)) { cin >> x >> y; adj[x].push_back(y); adj[y].push_back(x); } } void unique_elem(vector<long long int> &v) { sort(v.begin(), v.end()); auto ip = unique(v.begin(), v.end()); v.resize(distance(v.begin(), ip)); } void unique_elem_with_count(vector<long long int> &a, vector<long long int> &unique, vector<long long int> &cnt_unique, vector<long long int> &sum_unique, int n) { sort(a.begin(), a.end()); long long int j = 0; long long int sum = 0; while (j < n) { long long int cnt = 1; if (j != n - 1) { while (a[j + 1] == a[j]) { cnt++; j++; if (j == n - 1) { break; } } } sum += cnt; unique.push_back(a[j]); cnt_unique.push_back(cnt); sum_unique.push_back(sum); j++; } } vector<int> spf(1000005); void sieve() { spf[1] = 1; for (int i = 2; i < 1000005; i++) spf[i] = i; for (int i = 4; i < 1000005; i += 2) spf[i] = 2; for (int i = 3; i * i < 1000005; i++) { if (spf[i] == i) { for (int j = i * i; j < 1000005; j += i) { if (spf[j] == j) { spf[j] = i; } } } } } vector<int> getFactorization(int x) { vector<int> ret; map<int, int> fact; while (x != 1) { ret.push_back(spf[x]); if (fact.find(spf[x]) == fact.end()) { fact[spf[x]] = 1; } else { fact[spf[x]]++; } x = x / spf[x]; } for (auto it = fact.begin(); it != fact.end(); it++) { if (it->second & 1) { ret.push_back(it->first); } } return ret; } vector<long long int> factr(100005); vector<long long int> modinvr(100005); vector<long long int> modinvrfact(100005); void modularInverse() { modinvr[0] = modinvr[1] = 1; for (int i = 2; i < 100005; i++) modinvr[i] = modinvr[1000000007 % i] * (1000000007 - 1000000007 / i) % 1000000007; } void compute() { factr[0] = 1; modinvr[0] = 1; for (int(i) = (1); (i) < (100005); ++(i)) { factr[i] = (factr[i - 1] * i) % 1000000007; modinvrfact[i] = modinv(factr[i]) % 1000000007; } } void decToBinary(int n) { int binaryNum[32]; int i = 0; while (n > 0) { binaryNum[i] = n % 2; n = n / 2; i++; } } bool containsOnlyDigit(string str) { int l = str.length(); for (int i = 0; i < l; i++) { if (str.at(i) < '0' || str.at(i) > '9') return false; } return true; } void swap(int &first, int &second) { int temp = first; first = second; second = temp; } int str_to_num(string second) { return stoi(second); } string int_to_str(int n) { return to_string(n); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; cin >> t; int tt = 1; while (t--) { long double n; cin >> n; double pi = 2 * acos(0.0); long double r = 1.0 / (2 * (sin(pi / (2 * n)))); long double ans = sqrtl(2) * r * (sin(pi / 4 * (1 - 1.0 / n)) + sin(pi / 4 * (1 + 1.0 / n))); cout << fixed; cout << setprecision(7); cout << ans << '\n'; tt++; } }
#include <bits/stdc++.h> using namespace std; void canhazfast() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template <typename T> T extgcd(T a, T b, T &x, T &y) { T x0 = 1, y0 = 0, x1 = 0, y1 = 1; while (b) { T q = a / b; a %= b; swap(a, b); x0 -= q * x1; swap(x0, x1); y0 -= q * y1; swap(y0, y1); } x = x0; y = y0; return a; } int ctz(unsigned x) { return __builtin_ctz(x); } int ctzll(unsigned long long x) { return __builtin_ctzll(x); } int clz(unsigned x) { return __builtin_clz(x); } int clzll(unsigned long long x) { return __builtin_clzll(x); } int popcnt(unsigned x) { return __builtin_popcount(x); } int popcntll(unsigned long long x) { return __builtin_popcountll(x); } int bsr(unsigned x) { return 31 ^ clz(x); } int bsrll(unsigned long long x) { return 63 ^ clzll(x); } void solve() { int n; double r, ans; cin >> n; r = 1.0 / sin(M_PI / (2 * n)); ans = r * cos(M_PI / (4 * n)); cout << setprecision(8) << ans << '\n'; } int main() { canhazfast(); int t; cin >> t; for (; t; --t) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 200005, INF = 2000000000000000000; long long power(long long a, long long b, long long p) { if (a == 0) return 0; long long res = 1; a %= p; while (b > 0) { if (b & 1) res = (res * a) % p; b >>= 1; a = (a * a) % p; } return res; } vector<long long> prime; bool is_composite[N]; void sieve(long long n) { memset(is_composite, false, sizeof(is_composite)); for (long long i = 2; i < n; ++i) { if (!is_composite[i]) prime.push_back(i); for (long long j = 0; j < prime.size() && i * prime[j] < n; ++j) { is_composite[i * prime[j]] = true; if (i % prime[j] == 0) break; } } } void print(bool n) { if (n) { cout << "YES"; } else { cout << "NO"; } } long double pi = 2 * acos(0.0); int32_t main() { std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long T; cin >> T; while (T--) { long double n; cin >> n; n *= 2; long double ans = cos(pi / (2 * n)); ans /= sin(pi / n); cout << setprecision(12); cout << ans << "\n"; } }
#include <bits/stdc++.h> using namespace std; const double PI = 3.14159265358979323846264338327950288419716939937510582; int t; int n; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; cout << fixed << setprecision(20) << cos(PI / (4 * n)) / sin(PI / (2 * n)) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; while (t--) { long long n, N; cin >> n; N = 2 * n; long double ri, rc, ans, d; ri = (long double)(1 / (long double)(2 * tan((long double)3.1415926535897932 / N))); rc = (long double)(1 / (long double)(2 * sin((long double)3.1415926535897932 / N))); if (n % 2 == 0) { cout << setprecision(10) << 2 * ri; cout << "\n"; } else { cout << setprecision(10) << cos((long double)3.1415926535897932 / (2 * N)) / sin((long double)3.1415926535897932 / N); cout << "\n"; } } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize(2) using namespace std; inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar(); return x * f; } void solve() { int n; cin >> n; cout << fixed << setprecision(10) << cos(3.1415926 / (4 * n)) / sin(3.1415926 / (2 * n)) << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; long long t, n; long double PI = 3.14159265; int32_t main() { cin >> t; while (t--) { cin >> n; cout << setprecision(10) << (cos(PI / (4.0 * n)) / sin(PI / (2.0 * n))) << endl; } }
#include <bits/stdc++.h> using namespace std; int t, n; double maxx = 0, maxy = 0; bool check(double ang) { maxx = maxy = 0; for (int i = (0); i < (2 * n); i++) { double x = cos(i * (M_PI / n) + ang); double y = sin(i * (M_PI / n) + ang); maxx = max(maxx, x); maxy = max(maxy, y); } return maxx < maxy; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> t; cout << fixed << setprecision(8); while (t--) { cin >> n; double L = 0, R = M_PI / n; while (R - L > 1e-10) { double M = L + (R - L) / 2; if (check(M)) { L = M; } else { R = M; } } double r = 0.5 / sin(M_PI / (2 * n)); cout << maxx * 2 * r << endl; } }
#include <bits/stdc++.h> using namespace std; double minSquareEven(int n) { double angle = 2 * 3.14159265358979323846 / n; return 1 / tan(angle / 2); } double minSquareOdd(int n) { int k = n / 4 + 1; return sin((3 / 4.0 - 1.0 * k / n) * 3.14159265358979323846) / sin(3.14159265358979323846 / n); } int main() { int t; cin >> t; while (t--) { int n; cin >> n; cout << setprecision(50) << minSquareOdd(2 * n) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; double PI = acos(-1); double pre[500]; int caled[500]; double getRad(int n) { double theta = PI - (n - 2) * PI / n; double x = 0; double y = 0; double cth = 0; double r = 1; for (int i = 0; i < n; i++) { cth += theta; x += cos(cth); y += sin(cth); double dist = sqrt(x * x + y * y); r = max(r, dist / 2); } return r; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; n *= 2; if (caled[n]) { cout << fixed << setprecision(10) << pre[n] << endl; continue; } double r = getRad(n); double Theta = 2 * PI / n; double th = 0; double ans = 100010; while (th < 2 * PI) { double x = r * cos(th); double y = r * sin(th); double mnx = x, mxx = x; double mny = y, mxy = y; for (int i = 0; i < n; i++) { x = r * cos(Theta * i + th); y = r * sin(Theta * i + th); mnx = min(mnx, x); mxx = max(mxx, x); mny = min(mny, y); mxy = max(mxy, y); } double cur = max(mxx - mnx, mxy - mny); ans = min(ans, cur); th += 2 * PI / 1000; } caled[n] = 1; pre[n] = ans; cout << fixed << setprecision(10) << ans << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { long double pi = 3.14159265358979323846; int t; cin >> t; while (t--) { int n; cin >> n; if (n % 2 == 0) { long double angle = pi * (long double)(n - 1) / (2.0 * (long double)n); long double ans = tan(angle); cout << fixed << setprecision(6); cout << ans << endl; } else { long double angle[101], len[101]; long double internal_angle = pi * (long double)(n - 1) / ((long double)n); long double limit = (pi / 4.0); int k = (n - 1) / 2; int idx = -1; angle[k + 1] = (internal_angle / 2.0); for (int i = k; i >= 1; i--) { angle[i] = angle[i + 1] - (pi - internal_angle); if (idx == -1 && angle[i] < limit) { idx = i; } } len[1] = 1.0; for (int i = 2; i <= idx; i++) { len[i] = len[i - 1] + 2 * cos(angle[i]); } long double height = 0; for (int i = idx + 1; i <= k + 1; i++) { height += sin(angle[i]); } long double s = sqrt(2.0); long double ans = (len[idx] + 2.0 * height) / s; cout << fixed << setprecision(9); cout << ans << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { cout << fixed << setprecision(10); double n; cin >> n; n *= 2; cout << (cos(3.14159265359 / (2 * n)) / sin(3.14159265359 / n)) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 0.5; const double pi = acos(-1.0); const long long INF = 2e18; const int maxn = 100005; int main() { int t; scanf("%d", &t); while (t--) { int n; scanf("%d", &n); n = n + n; double ans = cos(pi / (2.0 * n)) / (sin(pi / (1.0 * n))); printf("%.10f\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll t; cin >> t; cout << fixed; while (t--) { ll s; cin >> s; ll n = 2 * s; cout << 1 / sin(3.14159265 / n) * cos(3.14159265 / 2 / n) << '\n'; } return 0; }
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; double n, t, k; string s; int main() { cin >> t; while (t--) { cin >> n; n *= 2.0; double ct = 360.0 / n / 2; ct = ct / 180.0 * 3.1415926535; ct = 1 / sin(ct); printf("%.10lf\n", ct * cos(3.1415926535 / n / 2)); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; for (; t > 0; t--) { double n, x, y; cin >> n; x = 1 / (2 * sin(3.14159265358979323846 / (2 * n))); y = sin((3.14159265358979323846 / 2) - (3.14159265358979323846 / (4 * n))); x = 2 * x * y; cout << fixed << setprecision(20) << x << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long power(long long x, long long y, long long p = 1000000007) { long long res = 1; x %= p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } int32_t main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); srand(chrono::high_resolution_clock::now().time_since_epoch().count()); long long t = 1; cin >> t; while (t--) { long long n; cin >> n; long double cr = 1 / (2 * (sin(3.14159265358979323846 / (2 * n)))); long double ans = 2 * cr * cos(3.14159265358979323846 / (4 * n)); cout << fixed << setprecision(9) << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; string s; int main() { int t; cin >> t; while (t--) { double pi = 3.14159265358979323; double n; cin >> n; double a = 1 / (2 * sin(pi / (4 * n))); cout << fixed << setprecision(10) << a << endl; } }
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; double u = 1.57079632679489661923 / n, po, no, so, ans = -1; po = 1 / sin(u); double l = (1.57079632679489661923 * 2) - (1.57079632679489661923 * 2) / n; l /= 2; l -= (1.57079632679489661923 * 2) / 4; for (int i = 1; i <= 2 * n; i++) { no = cos(l); so = no * po; ans = max(ans, so); l -= 1.57079632679489661923 / n; } printf("%.9f\n", ans); } int main() { int t; cin >> t; while (t--) { solve(); } }
#include <bits/stdc++.h> using namespace std; const int inf = 1012345678; const double pi = acos(-1.0); void solve() { cout << std::setprecision(20); int n; cin >> n; float ans = cos(pi / (4 * n)) / sin(pi / (2 * n)); cout << ans << "\n"; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); int t; cin >> t; while (t--) { solve(); } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("-ffloat-store") using namespace std; const long long mod = 998244353; const double pi = 3.14159265358979323846; long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n; cin >> n; double ang = pi / (4 * n); double x = 1 / (2 * sin(ang)); double ans = sqrt(x * x - 1); cout << setprecision(12) << x << "\n"; } }
#include <bits/stdc++.h> using namespace std; double getMinimumSideLength(int n) { if (n % 2 == 0) { double theta = M_PI / (2.0 * n); return 1 / tan(theta); } else { double N = 2.0 * n; return cos(M_PI / (2 * N)) / sin(M_PI / N); } } int main() { int tc; scanf("%d", &tc); while (tc--) { int n; scanf("%d", &n); double ans = getMinimumSideLength(n); printf("%.9lf\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long dx[] = {-1, 0, 1, 0}; long long dy[] = {0, -1, 0, 1}; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) { long long n; cin >> n; cout << setprecision(10) << fixed; cout << 0.5 / (sin(3.141592653589793238462643383279 / (4 * n))) << "\n"; } }
#include <bits/stdc++.h> using namespace std; long long int mod1 = 1000000007; long long int mod2 = 67280421310721; long long int mod3 = 998244353; long long int INF = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t; cin >> t; while (t--) { double n; cin >> n; long long int k = (n + 1) / 4; double sum = (sin((360 / (2 * n)) * k * (3.14159265358979323846264338 / 180)) + cos((360 / (2 * n)) * k * (3.14159265358979323846264338 / 180))) / (sqrt(2) * sin((360 / (4 * n)) * (3.14159265358979323846264338 / 180))); cout << setprecision(15) << (sum) << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; long long mo(const long long input, const long long ceil) { return input >= ceil ? input % ceil : input; } void solve(int tt) { long long n; cin >> n; long double pi = 3.141592653589793238; n *= 2; long double ans = 0.0; ans = cos(pi / (2 * n)) / sin(pi / n); cout << fixed << setprecision(12) << ans << "\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int tt = 1; cin >> tt; for (int i = 0; i < tt; i++) solve(tt); cerr << "\n\n\nTime : " << 1000 * (long double)clock() / (long double)CLOCKS_PER_SEC << "ms\n"; ; return 0; }
#include <bits/stdc++.h> using namespace std; long long int min(long long int a, long long int b) { if (a < b) return a; return b; } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); long long int TTCC = 1; cin >> TTCC; while (TTCC--) { long double n; cin >> n; n = n * 4; long double l = 1.0, a, b, angle_180 = 180.0, angle_90 = 90.0, x; x = l / (2.0 * sin(3.14159265358979323 / n)); cout << fixed << setprecision(9) << x << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const int NINF = 0xc0c0c0c0; const int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; const long long maxn = 1e6 + 5; const double pi = acos(-1.0); double cot(double x) { return cos(x) / sin(x); } void solve() { int n; scanf("%d", &n); n = 2 * n; double ans = 1.0 / cos((n - 2) * pi / 2.0 / n) * cos(pi / 2 / n); printf("%.10f\n", ans); } int main() { int T; scanf("%d", &T); while (T--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e2 + 10; const double PI = atan(1.0) * 4; int main() { int T; cin >> T; while (T--) { double n; int m; cin >> m; n = (double)m; double t = PI / n; double l = 0.5 / (sin(t / 2.0)); double p; if (m == 3) p = n / 4.0 - 0.5; else p = n / 4.0 - floor(n / 4.0); double ans1 = 2.0 * l * cos(p * t); double ans2 = 2.0 * l * cos((1.0 - p) * t); printf("%.10lf\n", max(ans1, ans2)); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T = double> T pi() { return acos(T(-1)); } bool __hack = std::ios::sync_with_stdio(false); auto __hack1 = cin.tie(nullptr); namespace template_util { constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; } template <int N> struct bytetype {}; template <uint64_t N> struct minimal_uint : bytetype<bytecount(N)> {}; } // namespace template_util template <class T> T next(istream& in) { T ret; in >> ret; return ret; } void solve(istream& in, ostream& out) { auto t = next<int>(in); while (t--) { auto n = next<int>(in); out << fixed << setprecision(15) << cos(pi() / (4. * n)) / (sin(pi() / (2. * n))) << "\n"; } } int main() { solve(cin, cout); return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 500; int T; int main() { cin >> T; while (T--) { int n; cin >> n; n *= 2; double ang = (n - 2) * acos(-1) / n; double tmp = (acos(-1) - ang) / 4; ang /= 2; double l = 1 / cos(ang); ang += tmp; double h = l * sin(ang); printf("%.10f\n", h); } }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; void solve() { long long i, j, n; cin >> n; double l = 0.5 / (sin(3.1415926535897932384626 / (2 * n))); double n1 = n / 2; double n2 = (n + 1) / 2; double ans = l * (sqrt(2.0)) * (cos((n1 * 3.1415926535897932384626) / (2 * n)) + cos((n2 * 3.1415926535897932384626) / (2 * n))); cout << fixed << setprecision(9) << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; cin >> t; while (t--) { solve(); } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { float n; cin >> n; cout << fixed << setprecision(9) << cos(3.141592653589 / (4 * n)) / sin(3.141592653589 / (2 * n)) << endl; } }
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b) { long long int result = 1; while (b > 0) { int lastbit = (b & 1); if (lastbit) { result = (result * a); } a = (a * a); b = b >> 1; } return result; } long long int power2(long long int a, long long int b, long long int p) { long long int result = 1; while (b > 0) { int lastbit = (b & 1); if (lastbit) { result = (result * a) % p; } a = (a * a) % p; b = b >> 1; } return result % p; } long long int gcd(long long int a, long long int b) { if (b == 0) return a; return gcd(b, a % b); } vector<int> SieveOfEratosthenes(int n) { bool prime[n + 1]; memset(prime, true, sizeof(prime)); for (int p = 2; p * p <= n; p++) { if (prime[p] == true) { for (int i = p * p; i <= n; i += p) prime[i] = false; } } vector<int> v; for (int p = 2; p <= n; p++) if (prime[p]) v.push_back(p); return v; } void InverseofNumber(long long int p) { long long int n[1000001]; n[0] = n[1] = 1; for (int i = 2; i <= 1000000; i++) n[i] = n[p % i] * (p - p / i) % p; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt; cin >> tt; while (tt--) { int n; cin >> n; n = n * 4; double d = 3.141592653589793238 / (n * 1.0); double x = sin(d) * 2.0; double y = 1 / (x * 1.0); cout << fixed; cout << setprecision(10) << y; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double PI = acos(-1); const double eps = 1e-6; const int mod = 1e9 + 7; const int N = 510; int n, a[N], b[N]; void sol() { int n; scanf("%d", &n); double ang = PI / n; double ans = 1.0 / sin(ang / 2.0) * cos(ang / 4.0); printf("%.7f\n", ans); } int main() { int _; scanf("%d", &_); while (_--) sol(); return 0; }
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long m) { long long r = 1; for (; y; y >>= 1) { if (y & 1) r = r * x % m; x = x * x % m; } return r; } const long long N = 1e3 + 5, M = 1e9 + 7; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); srand(time(NULL)); ; long long n, k, m = 0, x = 0, i, t = 1, ans = 0, j, y = 0, z = 0, c = 0, w, last = -1; double pi = acos(-1.0); cin >> t; while (t--) { cin >> n; n <<= 1; double X = 90.0 / n; cout << fixed << setprecision(9) << 0.5 / sin(X * pi / 180.0); cout << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { long long i, j, k, n, m, t, x, y, c, a, b, d, ans; cin >> t; while (t--) { cin >> n; double pi = 3.14159265358979323846, z; n = 2 * n; z = (pi / (n + 0.0) / 2); cout << setprecision(9) << fixed; cout << (1.0 / sin(z)) / 2.0 << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; long long i, j, k; void Anon_mouS() { long long n; cin >> n; cout << std::setprecision(9) << std::fixed; cout << cos(3.14159265358979323 / (4 * n)) / sin(3.14159265358979323 / (2 * n)) << '\n'; } int32_t main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); ; long long q = 1; cin >> q; while (q--) { Anon_mouS(); } return 0; }
#include <bits/stdc++.h> using namespace std; int cn; double s, n, pai = 3.1415927, m; int main() { cin >> cn; for (int ind = 0; ind < cn; ind++) { cin >> n; s = 0; m = 1 / n * 1.00000; for (double i = 0; i < n; i++) { s += sin((0.25 + i * m * 1.0000000) * pai); if (0.25 + i * m * 1.0000000 > 1) { s -= sin((0.25 + i * m * 1.0000000) * pai); s -= sin((0.25 + i * m * 1.0000000) * pai); } } printf("%.8lf", s); cout << endl; } }
#include <bits/stdc++.h> void rd(int &x) { x = 0; int f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); x *= f; } void lrd(long long &x) { x = 0; int f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar(); x *= f; } const int INF = 1e9; const long long LINF = 1e18; using namespace std; int T, n; int main() { rd(T); while (T--) { rd(n); double tmp = 1.0 / (1 - cos(acos(-1) / n)); printf("%.9lf\n", sqrt(tmp * 2) * cos(acos(-1) / n / 4)); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int t, n; cin >> t; while (t--) { cin >> n; cout << setprecision(15) << (double)cos(1.57079632679489661923 / (2 * n)) / sin(1.57079632679489661923 / n) << endl; } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; long double pi = 3.14159265359; int main() { int t; cin >> t; while (t--) { long double n; cin >> n; n *= 2; long double r = 1 / (2 * sin(pi / n)); long double ang = ((2 * pi) / n); long double maxi = 0.0; for (int i = 0; i < n / 4 + 1; i++) { long double x = r * sin(((long double)i) * ang); long double y = r * cos(((long double)i) * ang); maxi = max(maxi, ((x + y) * 2.0) / sqrt(2.0)); } cout << setprecision(50) << maxi << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int mxn = 1e6; int n; int t; int main() { cin >> t; while (t--) { cin >> n; n = 2 * n; float div = 3.14159265358979 / n; float val1 = sin(div); float val2 = cos(div / 2); float in = val2 / val1; printf("%.9f\n", in); } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20); long long int tt; cin >> tt; while (tt--) { long double n; cin >> n; long double r, s, c; long long int m = n / 2 + 1; ; vector<long double> sins(m), coss(m); coss[0] = 1.0; for (auto i = 1; i <= m - 1; i++) { sins[i] = sin(i * (180.0 / n) * (3.14159265359 / 180.0)); coss[i] = cos(i * (180.0 / n) * (3.14159265359 / 180.0)); } s = 0, c = 0; for (auto i = 1; i <= m - 1; i++) { if (min((s), (c)) < min((sins[i]), (coss[i]))) { s = sins[i]; c = coss[i]; } } r = 1.0 / (2.0 * sin((90.0 / n) * (3.14159265359 / 180.0))); cout << (sqrt(2) * (c + s) * r) << '\n'; }; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const double PI = acos(-1); template <class T> inline void read(T &res) { char c; T flag = 1; while ((c = getchar()) < '0' || c > '9') if (c == '-') flag = -1; res = c - '0'; while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0'; res *= flag; } int t, n; int main() { cin >> t; while (t--) { cin >> n; double a = PI / (n * 2); double r = 1 / sin(a); a /= 2; printf("%lf\n", r * cos(a)); } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; template <typename T> istream& operator>>(istream& in, vector<T>& a) { for (auto& i : a) in >> i; return in; } template <typename T> ostream& operator<<(ostream& out, vector<T>& a) { for (auto& i : a) out << i << " "; return out; } template <typename T, typename U> void chkmin(T& a, U b) { if (a > b) a = b; } template <typename T, typename U> void chkmax(T& a, U b) { if (a < b) a = b; } const double PI = atan2(0, -1); void solve() { int n; cin >> n; n *= 2; long double r = 1 / (2 * sin(PI / n)); vector<pair<long double, long double>> points; long double alpha = 2 * PI / n; for (int i = (int)0; i < (int)n; i++) { pair<long double, long double> cur = {r * cos(alpha * i), r * sin(alpha * i)}; if (cur.first >= 0 && cur.second >= 0) points.push_back(cur); } auto check = [&](long double M) -> bool { for (auto [x, y] : points) if (y > M - x) return false; return true; }; long double L = 0, R = 1e9; for (int i = (int)0; i < (int)100; i++) { long double M = (L + R) / 2; if (check(M)) R = M; else L = M; } long double ans = L; points.clear(); for (int i = (int)0; i < (int)n; i++) { pair<long double, long double> cur = {r * cos(alpha * i + alpha / 2), r * sin(alpha * i + alpha / 2)}; if (cur.first >= 0 && cur.second >= 0) points.push_back(cur); } L = 0, R = 1e9; for (int i = (int)0; i < (int)100; i++) { long double M = (L + R) / 2; if (check(M)) R = M; else L = M; } chkmin(ans, L); cout << fixed << setprecision(10) << sqrt(2) * ans << "\n"; } int main() { ios_base::sync_with_stdio(0), cin.tie(0); int t; cin >> t; while (t-- > 0) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); long long t, n; int main() { cin >> t; while (t--) { scanf("%d", &n); double A = PI / (n * 2); double R = 1 / sin(A); A /= 2; printf("%.10lf\n", R * cos(A)); } return 0; }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos((long double)-1.0); const double EPS = 1e-8; const int MOD = 1e9 + 7; template <typename T> void cmin(T& x, T y) { if (y < x) x = y; } template <typename T> void cmax(T& x, T y) { if (y > x) x = y; } long long qpow(long long x, long long n, long long mod = MOD) { if (n < 0) return 0; long long res = 1; while (n) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } long long sq(long long x) { return x * x; } double sq(double x) { return x * x; } struct Vector { double x, y; Vector() {} Vector(double x, double y) : x(x), y(y) {} double length() { return sqrt(x * x + y * y); } Vector operator+(const Vector& v) const { return Vector(x + v.x, y + v.y); } Vector operator-(const Vector& v) const { return Vector(x - v.x, y - v.y); } Vector operator*(const double& k) const { return Vector(k * x, k * y); } Vector operator/(const double& k) const { return Vector(x / k, y / k); } Vector rotate(double k) { return Vector(x * cos(k) - y * sin(k), x * sin(k) + y * cos(k)); } void show() { printf("%.12f %.12f\n", x, y); } }; namespace Solver { void InitOnce() { int t; scanf("%d", &t); } int n; void Read() { int res = scanf("%d", &n); if (res == -1) exit(0); } double a, r; double Build(double d) { Vector v1(r, 0.0); v1 = v1.rotate(d); double x1, x2, y1, y2; x1 = LINF, x2 = -LINF; y1 = LINF, y2 = -LINF; for (int i = 1; i <= n; ++i) { cmin(x1, v1.x); cmin(y1, v1.y); cmax(x2, v1.x); cmax(y2, v1.y); v1 = v1.rotate(a); } double ans = max(x2 - x1, y2 - y1); return ans; } double RandDouble() { return 1.0 * rand() / RAND_MAX; } void Solve() { n *= 2; a = 2.0 * PI / n; r = (0.5) / (sin(a / 2.0)); double L = 0, R = a; for (int t = 600; t; --t) { double M1 = L + 1.0 * (R - L) / 3.0; double M2 = L + 2.0 * (R - L) / 3.0; double ans1 = Build(M1); double ans2 = Build(M2); if (ans1 < ans2) R = M2; else L = M1; } double ans = Build((L + R) / 2.0); printf("%.12f\n", ans); return; } } // namespace Solver int main() { Solver::InitOnce(); while (1) { Solver::Read(); Solver::Solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int mo = 1e9; long long ksm(long long a, long long b) { if (b < 0) return 0; long long ans = 1; while (b) { if (b & 1) ans = ans * a % 1000000007; a = a * a % 1000000007; b >>= 1; } return ans; } int t; double n; int main() { scanf("%d", &t); while (t--) { scanf("%lf", &n); const double pi = acos(-1.0); double s = cos(pi / (4 * n)) / sin(pi / (2 * n)); printf("%.9f\n", s); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { long long int a; cin >> a; double n = 2.0 * a; printf("%.12lf\n", 1.0 / (2 * sin(2 * acos(0.0) / 2 / n))); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; long double ans = cos(3.14159265359 / (4.0 * n)) / sin(3.14159265359 / (2.0 * n)); cout << fixed << setprecision(10) << ans << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { long long n; cin >> n; printf("%.9f\n", 1 / (2 * sin(3.14159265 / (4 * n)))); } return 0; }
#include <bits/stdc++.h> using namespace std; const long double pi = 3.14159265358979323846; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); long double tt; cin >> tt; while (tt--) { long double n; cin >> n; long double ans; ans = (long double)(cos((long double)pi / (4 * n))); ans = (long double)ans / (sin((long double)pi / (2 * n))); cout << fixed << setprecision(10) << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long k = 1e5 + 1; long long fast_pow(long long base, long long n, long long m) { if (n == 0) return 1; if (n == 1) return base; long long halfn = fast_pow(base, n / 2, m); if (n % 2 == 0) return (halfn * halfn) % m; else return (((halfn * halfn) % m) * base) % m; } long long findMMI_fermat(long long n, long long m) { return fast_pow(n, m - 2, m); } signed main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long q; cin >> q; while (q--) { double n; cin >> n; double ans = 1 / (sin(3.14159265358979323846 / (n * 2))) * (cos(3.14159265358979323846 / (n * 4))); cout << setprecision(20) << ans << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int t, n; cin >> t; while (t--) { scanf("%d", &n); printf("%.7f\n", 1 / (2 * (sin(3.14159265 / (4 * n))))); } }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos((long double)-1.0); const double EPS = 1e-8; const int MOD = 1e9 + 7; template <typename T> void cmin(T& x, T y) { if (y < x) x = y; } template <typename T> void cmax(T& x, T y) { if (y > x) x = y; } long long qpow(long long x, long long n, long long mod = MOD) { if (n < 0) return 0; long long res = 1; while (n) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } long long sq(long long x) { return x * x; } double sq(double x) { return x * x; } struct Vector { double x, y; Vector() {} Vector(double x, double y) : x(x), y(y) {} double length() { return sqrt(x * x + y * y); } Vector operator+(const Vector& v) const { return Vector(x + v.x, y + v.y); } Vector operator-(const Vector& v) const { return Vector(x - v.x, y - v.y); } Vector operator*(const double& k) const { return Vector(k * x, k * y); } Vector operator/(const double& k) const { return Vector(x / k, y / k); } Vector rotate(double k) { return Vector(x * cos(k) - y * sin(k), x * sin(k) + y * cos(k)); } void show() { printf("%.12f %.12f\n", x, y); } }; namespace Solver { void InitOnce() { int t; scanf("%d", &t); } int n; void Read() { int res = scanf("%d", &n); if (res == -1) exit(0); } double a, r; double Build(double d) { Vector v1(r, 0.0); v1 = v1.rotate(d); double x1, x2, y1, y2; x1 = LINF, x2 = -LINF; y1 = LINF, y2 = -LINF; for (int i = 1; i <= n; ++i) { cmin(x1, v1.x); cmin(y1, v1.y); cmax(x2, v1.x); cmax(y2, v1.y); v1 = v1.rotate(a); } double ans = max(x2 - x1, y2 - y1); return ans; } double RandDouble() { return 1.0 * rand() / RAND_MAX; } void Solve() { n *= 2; a = 2.0 * PI / n; r = (0.5) / (sin(a / 2.0)); double L = 0, R = a; for (int t = 100; t; --t) { double M1 = L + 1.0 * (R - L) / 3.0; double M2 = L + 2.0 * (R - L) / 3.0; double ans1 = Build(M1); double ans2 = Build(M2); if (ans1 < ans2) R = M2; else L = M1; } double ans = Build((L + R) / 2.0); printf("%.12f\n", ans); return; } } // namespace Solver int main() { Solver::InitOnce(); while (1) { Solver::Read(); Solver::Solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; long long powmod(long long a, long long l, long long md) { a %= md; long long res = 1; while (l) { if (l & 1) res = res * a % md; l /= 2; a = a * a % md; } return res; } long long binpow(long long a, long long l) { long long res = 1; while (l) { if (l & 1) res = res * a; l /= 2; a = a * a; } return res; } long long invmod(long long a, long long md) { return powmod(a, md - 2, md); } long long __set(long long b, long long i) { return b | (1LL << i); } long long __unset(long long b, long long i) { return b & (~(1UL << i)); } long long __check(long long b, long long i) { return b & (1LL << i); } long long mulmod(long long a, long long b, long long md) { return (((a % md) * (b % md)) % md + md) % md; } long long addmod(long long a, long long b, long long md) { return ((a % md + b % md) % md + md) % md; } long long submod(long long a, long long b, long long md) { return (((a % md - b % md) % md) + md) % md; } long long divmod(long long a, long long b, long long md) { return mulmod(a, powmod(b, md - 2, md), md); } const long long inf = 0xFFFFFFFFFFFFFFFL; priority_queue<long long, vector<long long>, greater<long long> > pq; const long long MOD = 998244353; signed main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long t; cin >> t; while (t--) { long long n; cin >> n; long long s = 2 * n; long double multiplier = 1 / (sqrt(2) * sin(3.14159265358979323846 / (long double)s)); long double theta = (long double)2 * 3.14159265358979323846 / (long double)s; long double alpha = theta; long double ans = -1; while (alpha <= 3.14159265358979323846 / (long double)2) { ans = max(ans, multiplier * (sin(alpha) + cos(alpha))); alpha += theta; } cout << setprecision(10) << ans << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; double across(int n, int num_sides) { double ang = M_PI * ((double)num_sides / n) / 2; return 0.5 / sin(M_PI / (2 * n)) * sin(ang) * 2; } int main() { cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; double arg = (M_PI * (n - 1)) / ((double)2 * n); if (n % 2 == 0) { cout << setprecision(50) << tan(arg) << "\n"; } else { double r = 0.5 / sin(M_PI / (2 * n)); double side = r * 2 * sin((M_PI / n * (n - 1)) / 2); cout << setprecision(50) << sqrt(pow(across(n, n / 2), 2) / (double)2) + sqrt(pow(across(n, n / 2 + 1), 2) / (double)2) << "\n"; } } }
#include <bits/stdc++.h> using namespace std; const double pi = 3.1415926535897; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; scanf("%d", &t); while (t--) { long long n; scanf("%lld", &n); double ans = ((pi) / (2.0 * n)); printf("%.10lf\n", 1.0 / (sin(ans) / cos(ans / 2.0))); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; double x = 0.5 / sin(3.14159265358979323846 / (2 * n)) * 2; printf("%.10lf\n", 1 / sin(3.14159265358979323846 / (2 * n)) * cos(3.14159265358979323846 / (4 * n))); } return 0; }
#include <bits/stdc++.h> using namespace std; long long n, m, k, x, y, z, a1, b, c, d, i, j; void sol() { cin >> n; double r1 = 1.0 / (2 * sin(3.14159265358979323846 / (4 * n))); cout << fixed << setprecision(9) << r1 << '\n'; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) sol(); return 0; }
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); void solve() { int n; scanf("%d", &n); printf("%.10lf\n", 0.5 / sin(pi / 4 / n)); } int main() { int T; scanf("%d", &T); while (T--) solve(); }
#include <bits/stdc++.h> using namespace std; const long long M = 5005; const int MOD = 998244353; const int MX = 3e5 + 5; const long long INF = 1e18; const long double PI = acos((long double)-1); void msm() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } int sol(); int main() { msm(); long long t; cin >> t; ; while (t--) sol(); return 0; } int sol() { long double x; cin >> x; long double ans = .5 / sin(PI / x / 4); cout << fixed << setprecision(20) << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int fx[] = {1, -1, 0, 0}; int fy[] = {0, 0, 1, -1}; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; for (int tc = 1; tc <= t; tc++) { int n; cin >> n; cout << fixed << setprecision(10) << cos(acos(-1.0) / (4 * n)) / sin(acos(-1.0) / (2 * n)) << '\n'; } }
#include <bits/stdc++.h> using namespace std; const long double pi = acosl(-1); long double raidan(long double x) { return (x * pi) / 180; } int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); int i, j; int t; cin >> t; while (t--) { long double n; cin >> n; long double ang = ((2 * n - 2) * 180) / (2 * n); long double a = ang - 90; long double ans = 0, ans2 = 0; for (i = 0; i < (int)(n / 2); i++) { ans += sinl(raidan(a)); ans2 += cosl(raidan(a)); a = ang - (180 - a); } ans2 *= 2; ans *= 2; ans += 1; ans *= sinl(raidan((90 + ang / 2) / 2)); cout << fixed << setprecision(9) << ans << "\n"; } }
#include <bits/stdc++.h> using namespace std; double n; int t; int main() { cin >> t; while (t) { t--; cin >> n; cout.precision(12); cout << cos(3.14159265359 / (4 * n)) / sin(3.14159265359 / (2 * n)) << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } template <typename T> inline void read(T& x) { x = 0; T fg = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') fg = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); x = fg * x; } template <typename T, typename... Args> inline void read(T& x, Args&... args) { read(x), read(args...); } template <typename T> inline void write(T x) { int len = 0; char c[21]; if (x < 0) putchar('-'), x = -x; do { ++len; c[len] = x % 10 + '0'; } while (x /= 10); for (int i = len; i >= 1; i--) putchar(c[i]); } template <typename T, typename... Args> inline void write(T x, Args... args) { write(x), write(args...); } struct Point { double x, y; Point(double _x = 0, double _y = 0) : x(_x), y(_y) {} Point operator+(const Point& a) const { return Point{x + a.x, y + a.y}; } Point operator-(const Point& a) const { return Point{x - a.x, y - a.y}; } Point operator*(double t) const { return Point{x * t, y * t}; } Point operator/(double t) const { return Point{x / t, y / t}; } Point turn(double rad) { return Point(x * cos(rad) - y * sin(rad), x * sin(rad) + y * cos(rad)); } }; double dis(Point p1, Point p2) { double tmp = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y); return sqrt(tmp); } double PI = acos(-1); double fans[205]; int main() { int t; read(t); while (t--) { int n; read(n); if (fans[n] < 1e-6) { double theta = PI / (double)n; int cnt = 1000; double ans = 2 * n; double r = 0, gap = PI / cnt; for (; cnt--; r += gap) { Point b(0.0, 0.0); Point v(cos(r), sin(r)); double mxx = 0, mnx = 0; double mxy = 0, mny = 0; for (int i = 1; i <= 2 * n; i++) { ckmax(mxx, b.x); ckmin(mnx, b.x); ckmax(mxy, b.y); ckmin(mny, b.y); b = b + v; v = v.turn(theta); } ckmin(ans, max(mxx - mnx, mxy - mny)); } fans[n] = ans; } printf("%.8lf\n", fans[n]); } return 0; }
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = pi / 180.0; int main() { int t; cin >> t; while (t--) { double n; cin >> n; double angle = 180.0 / n; double first = 1.0 / 2.0 / sin(angle / 2.0 * eps); double a1 = 180.0 / n * round(n / 4.0); double a2 = 90 - a1; double ans = first * (sin(a1 * eps) + sin(a2 * eps)) / sin(45.0 * eps); printf("%.9lf\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; long long TestCases, N, a, b; int main() { cin >> TestCases; while (TestCases--) { cin >> N; a = 0; b = 0; while (N % 3 == 0) { N /= 3; b++; a++; } while (N % 2 == 0) { N /= 2; a--; } if (N != 1 || a < 0) { cout << -1 << endl; } else { cout << a + b << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; int two = 0, three = 0; while (n % 2 == 0) two++, n /= 2; while (n % 3 == 0) three++, n /= 3; if (n != 1 || two > three) cout << -1 << endl; else { cout << 2 * three - two << endl; } } }
#include <bits/stdc++.h> using namespace std; signed main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long k = n % 3, z = 0; if (n == 1) cout << "0" << endl; else if (k != 0) cout << "-1" << endl; else { while (n % 6 == 0) { n /= 6; z++; } while (n % 3 == 0) { n /= 3; z += 2; } if (n == 1) cout << z << endl; else cout << "-1" << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int to = 0, th = 0; while (n % 2 == 0) { to++; n /= 2; } while (n % 3 == 0) { th++; n /= 3; } if (to > th || n != 1) { cout << "-1" << "\n"; } else { cout << th + (th - to) << "\n"; } } }
#include <bits/stdc++.h> using namespace std; void type(int n, int a, int b) { int now = -1; string s = ""; for (long long int i = 0; i < a; i++) { if (b != 0) now++, b--; s += char('a' + now); } for (long long int i = 0; i < n; i++) cout << s[i % a]; cout << endl; } const int mx = 1e6; int t, n, cnt; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while (t--) { cin >> n; while (n % 3 == 0) { if (n % 6 == 0) n /= 6; else if (n % 3 == 0) n /= 3, cnt++; cnt++; } if (n >= 2) cnt = -1; cout << cnt << endl; cnt = 0; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n, count = 0; cin >> n; for (int i = 0; n != 1; i++) { if (n % 6 == 0) { n = n / 6; count++; } else { n = n * 2; count++; } if (n > 1e9) { count = -1; break; } } cout << count << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; int cnt2 = 0, cnt3 = 0; cin >> n; while (n % 3 == 0) { n /= 3; cnt3++; } while (n % 2 == 0) { n /= 2; cnt2++; } if (cnt2 > cnt3 || n != 1) cout << "-1" << endl; else cout << cnt3 - cnt2 + cnt3 << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int GetNumSteps(int n) { int numSteps = 0; if (n != 1 && n % 3 != 0) return -1; while (n != 1) { if (n != 1 && n % 3 != 0) return -1; if (n % 6 == 0) n /= 6; else n *= 2; numSteps++; } return numSteps; } void solve(int arr[], int size) { for (int i = 0; i < size; i++) { cout << GetNumSteps(arr[i]) << endl; } } int main() { int t; cin >> t; int n[t]; for (int i = 0; i < t; i++) { cin >> n[i]; } solve(n, t); }
#include <bits/stdc++.h> using namespace std; int main() { long int t; cin >> t; while (t--) { long long n; cin >> n; unordered_map<int, long long> mmap; while (n % 3 == 0) { mmap[3]++; n /= 3; } while (n % 2 == 0) { mmap[2]++; n /= 2; } if ((n > 1) || (mmap[2] > mmap[3])) cout << -1 << endl; else { long long count = mmap[3]; count += (mmap[3] - mmap[2]); cout << count << endl; } } return 0; }