text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int prevp, prevc;
bool ok = true;
for (int i = 0; i < n; i++) {
int p, c;
cin >> p >> c;
if (c > p) {
ok = false;
}
if (i == 0) {
prevp = p;
prevc = c;
continue;
}
if (p < prevp || c < prevc) {
ok = false;
}
if (p - prevp < c - prevc) {
ok = false;
}
prevp = p;
prevc = c;
}
if (ok)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long f = 0;
long long n;
cin >> n;
long long a[n], b[n];
for (long long i = 0; i < n; i++) cin >> a[i] >> b[i];
if (b[0] <= a[0]) {
for (long long i = 1; i < n; i++) {
if (b[i] <= a[i] && a[i] - a[i - 1] >= b[i] - b[i - 1]) {
if (a[i] > a[i - 1] && b[i] >= b[i - 1]) {
continue;
} else if (a[i] == a[i - 1] && b[i] == b[i - 1]) {
continue;
} else {
f = 1;
break;
}
} else {
f = 1;
break;
}
}
if (f)
cout << "NO\n";
else
cout << "YES\n";
} else
cout << "NO\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, i, ck = 0;
cin >> t;
while (t--) {
cin >> n;
int p[n], c[n];
for (i = 0; i < n; i++) cin >> p[i] >> c[i];
if (n == 1) {
if (p[n - 1] >= c[n - 1])
ck = 1;
else
ck = 0;
} else {
for (i = 0; i < n - 1; i++) {
if ((p[i + 1] >= p[i] && c[i + 1] >= c[i]) &&
(p[i + 1] - p[i] >= c[i + 1] - c[i]) && (p[i] >= c[i]))
ck = 1;
else {
ck = 0;
break;
}
}
}
if (ck)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
template <class nmsl>
inline void read(nmsl &x) {
x = 0;
char ch = getchar(), w = 0;
while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
x = w ? -x : x;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int i;
int prev = 0;
int prevc = 0;
int f = 1;
for (int i = 0; i < int(n); i++) {
int x, y;
cin >> x >> y;
if (x >= prev && (y - prevc <= x - prev) && y <= x && y >= prevc) {
prev = x;
prevc = y;
continue;
} else {
f = 0;
}
}
if (f == 0)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, i, j, k, l, n, m;
cin >> t;
while (t--) {
cin >> n;
long long int p[n], c[n];
for (i = 0; i < n; i++) cin >> p[i] >> c[i];
int fl = 1;
for (i = 0; i < n; i++) {
if (c[i] > p[i]) {
fl = 0;
break;
}
}
for (i = 1; i < n; i++) {
if (p[i] < p[i - 1] || c[i] < c[i - 1]) {
fl = 0;
break;
}
}
for (i = 1; i < n; i++) {
k = p[i] - p[i - 1];
l = c[i] - c[i - 1];
if (k < l) {
fl = 0;
break;
}
}
if (fl)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void Fastio() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
long long fact[1000006], inv[1000006];
long long fp(long long base, long long exp) {
if (exp == 0) return 1;
long long ans = fp(base, exp / 2);
ans = (ans * ans) % 998244353;
if (exp % 2 != 0) ans = (ans * (base % 998244353)) % 998244353;
return ans;
}
void calcFacAndInv(long long n) {
fact[0] = inv[0] = 1;
for (long long i = 1; i <= n; i++) {
fact[i] = (i * fact[i - 1]);
inv[i] = fp(fact[i], 998244353 - 2);
}
}
long long ncr(long long n, long long r) {
return ((fact[n] * inv[r]) % 998244353 * inv[n - r]) % 998244353;
}
long long npr(long long n, long long r) {
return (fact[n] * inv[n - r]) % 998244353;
}
long double NCR(int n, int m) {
long double res = 1;
m = min(m, n - m);
for (int i = 0; i < m; i++) {
res = res * (n - i) / (i + 1);
}
return res;
}
long long tol(string a) {
long long res = 0;
while (a[0] == '0') {
a.erase(a.begin());
}
if (a == "") a = "0";
for (int i = 0; i < a.size(); i++) {
res *= 10;
res += a[i] - '0';
}
return res;
}
int check(string a, string b) {
for (int i = 0; i < a.size(); i++) {
if (a[i] > b[i]) return 1;
if (b[i] > a[i]) return -1;
}
return 0;
}
class data {
public:
long long v, d, p;
data() {}
data(long long vv, long long dd, long long pp) {
v = vv;
d = dd;
p = pp;
}
};
int primeFactors(int n) {
long long c = 0;
while (n % 2 == 0) {
c++;
n = n / 2;
}
for (int i = 3; i * i <= n; i = i + 2) {
while (n % i == 0) {
c++;
n = n / i;
}
}
if (n > 2) c++;
return c;
}
int main() {
Fastio();
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
pair<int, int> arr[n];
bool st = 1;
for (int i = 0; i < n; i++) {
cin >> arr[i].first >> arr[i].second;
if (!i) {
if (arr[i].first < arr[i].second) st = 0;
continue;
}
int tmp1, tmp2;
tmp1 = arr[i].first - arr[i - 1].first;
tmp2 = arr[i].second - arr[i - 1].second;
if (tmp1 < 0 || tmp2 < 0) st = 0;
if (tmp1 < tmp2) st = 0;
}
if (st)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int p, c;
cin >> p >> c;
bool f = true;
if (p < c) f = false;
for (int i = 2; i <= n; i++) {
int a, b;
cin >> a >> b;
if (a - p < b - c) {
f = false;
}
if (a < p || b < c) {
f = false;
}
if (a < b) f = false;
p = a;
c = b;
}
if (f)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
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;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int t;
int n;
int x, y;
int main() {
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
scanf("%d%d", &x, &y);
bool f = false;
int prex = x, prey = y;
if (x < y) f = true;
for (int i = 1; i < n; i++) {
scanf("%d%d", &x, &y);
if (x < y) f = true;
if (x >= prex && y < prey) f = true;
if (x < prex) f = true;
int maxx = x - prex + prey;
if (x >= prex && y > maxx) f = true;
prex = x;
prey = y;
}
if (f)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int n, k, m, d, t;
vector<pair<long long int, long long int> > v;
long long int p[105];
long long int c[105];
int main() {
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p[i] >> c[i];
}
int flag = 1;
if (n == 1) {
if (c[0] > p[0]) {
flag = 0;
}
}
for (int i = 0; i < (n - 1); i++) {
if ((p[i + 1] < p[i]) || (c[i + 1] < c[i])) {
flag = 0;
break;
}
if ((c[i + 1] - c[i]) > (p[i + 1] - p[i])) {
flag = 0;
break;
}
if (c[i] > p[i]) {
flag = 0;
break;
}
}
if (c[n - 1] > p[n - 1]) {
flag = 0;
}
if (flag) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
void run();
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(18);
run();
return 0;
}
void run() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<Pii> stats(n);
for (auto& k : (stats)) cin >> k.first >> k.second;
bool ans = 1;
if (stats[0].first < stats[0].second) {
ans = 0;
} else {
for (int i = (1); i < (n); i++) {
int a = stats[i].first - stats[i - 1].first;
int b = stats[i].second - stats[i - 1].second;
if (a < 0 || b < 0 || a < b) {
ans = 0;
break;
}
}
}
cout << (ans ? "YES\n" : "NO\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
vector<string> solve(const vector<vector<pair<int, int>>> _data) {
vector<string> res;
int last_t = 0;
int last_w = 0;
bool a = false;
for (vector<pair<int, int>> vec : _data) {
last_t = vec[0].first;
last_w = vec[0].second;
if (last_w > last_t) {
res.push_back("NO");
continue;
} else {
if (vec.size() > 1) {
a = false;
for (int i = 1; i < vec.size(); ++i) {
last_w = vec[i - 1].second;
last_t = vec[i - 1].first;
if (last_t <= vec[i].first && last_w <= vec[i].second) {
if ((vec[i].second - last_w) > (vec[i].first - last_t)) {
res.push_back("NO");
a = true;
break;
}
} else {
res.push_back("NO");
a = true;
break;
}
}
if (!a) res.push_back("YES");
} else if (vec.size() == 1) {
res.push_back("YES");
continue;
}
}
}
return res;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
vector<vector<pair<int, int>>> data(t);
for (int k = 0; k < t; ++k) {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int v1, v2;
cin >> v1 >> v2;
data[k].push_back(make_pair(v1, v2));
}
}
vector<string> _res = solve(data);
for (string s : _res) cout << s << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin >> q;
int p, c, p1, c1;
while (q--) {
cin >> n;
bool ans = true;
cin >> p >> c;
if (c > p) ans = false;
for (int i = 1; i < n; i++) {
cin >> p1 >> c1;
if (c1 > p1) ans = false;
if (!((p1 > p && c1 == c) || (p1 == p && c1 == c) ||
(c1 > c && p1 > p && p1 - p >= c1 - c)))
ans = false;
c = c1;
p = p1;
}
if (ans) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
int p[n];
int c[n];
for (int i = 0; i < n; i++) {
cin >> p[i] >> c[i];
}
if (p[0] < c[0]) {
cout << "NO\n";
return;
}
for (int i = 1; i < n; i++) {
if ((p[i] < p[i - 1]) || (c[i] < c[i - 1]) ||
(p[i] - p[i - 1] < c[i] - c[i - 1])) {
cout << "NO\n";
return;
}
}
cout << "YES\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t > 0) {
int n;
cin >> n;
int a[n], b[n];
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
if (a[0] < b[0]) {
cout << "NO" << endl;
goto label;
}
for (int i = 1; i < n; i++) {
if (a[i] < a[i - 1]) {
cout << "NO" << endl;
goto label;
}
if (b[i] < b[i - 1]) {
cout << "NO" << endl;
goto label;
}
if (a[i] - a[i - 1] < b[i] - b[i - 1]) {
cout << "NO" << endl;
goto label;
}
}
cout << "YES" << endl;
label:
t--;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long int a[105], b[105];
int main() {
long long int t;
cin >> t;
while (t--) {
long long int n, i, count;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
count = 0;
for (i = 1; i <= n; i++)
if (a[i] >= a[i - 1] && b[i] >= b[i - 1] &&
a[i] - a[i - 1] >= b[i] - b[i - 1]) {
continue;
} else {
count = 1;
}
if (count)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
for (int w = 0; w < q; w++) {
int n;
cin >> n;
int p[n], c[n];
for (int i = 0; i < n; i++) {
cin >> p[i] >> c[i];
}
bool isValid = true;
if (p[0] < c[0]) {
isValid = false;
cout << "NO\n";
continue;
}
for (int i = 1; i < n; i++) {
if (p[i] < p[i - 1] || c[i] < c[i - 1] || c[i] > p[i] ||
(c[i] - c[i - 1]) > (p[i] - p[i - 1])) {
isValid = false;
break;
}
}
if (isValid)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int cr;
cin >> cr;
int p[cr], c[cr];
for (int i = 0; i < cr; i++) {
cin >> p[i] >> c[i];
}
string ans = "YES";
for (int i = 1; i < cr; i++) {
if (((p[i] < p[i - 1]) ||
((c[i] < c[i - 1]) || (c[i] - c[i - 1] > p[i] - p[i - 1])))) {
ans = "NO";
break;
}
}
if (c[0] > p[0])
cout << "NO" << endl;
else
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int p[105], c[105];
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> p[i] >> c[i];
int f = 1;
for (int i = 1; i <= n; i++) {
if (c[i] > p[i]) f = 0;
if (p[i] < p[i - 1] || c[i] < c[i - 1]) f = 0;
if (p[i] - p[i - 1] < c[i] - c[i - 1]) f = 0;
}
if (f)
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tcase;
cin >> tcase;
while (tcase--) {
long long int n, i;
cin >> n;
vector<pair<long long int, long long int> > v;
for (i = 0; i < n; i++) {
long long int x, y;
cin >> x >> y;
v.push_back(make_pair(x, y));
}
if (n == 1) {
if (v[0].first >= v[0].second)
cout << "YES\n";
else
cout << "NO\n";
} else {
if (v[0].first >= v[0].second) {
bool flag = true;
for (i = 1; i < n; i++) {
if (v[i].first >= v[i - 1].first and
v[i].second >= v[i - 1].second and v[i].first >= v[i].second and
v[i].first - v[i - 1].first >= v[i].second - v[i - 1].second)
continue;
else {
flag = false;
break;
}
}
if (!flag)
cout << "NO\n";
else
cout << "YES\n";
} else
cout << "NO\n";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n][2];
for (int i = (0); i < (n); i++) cin >> a[i][0] >> a[i][1];
if (a[0][0] < a[0][1]) {
cout << "NO" << endl;
continue;
}
for (int i = (1); i < (n); i++) {
if (a[i][0] < a[i - 1][0] || a[i][1] < a[i - 1][1]) {
cout << "NO" << endl;
goto out;
} else if ((a[i][0] - a[i - 1][0]) < (a[i][1] - a[i - 1][1])) {
cout << "NO" << endl;
goto out;
}
}
cout << "YES" << endl;
out:;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int c[120], p[120];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout.precision(16);
;
int t;
cin >> t;
while (t--) {
int n, flag = 0;
cin >> n;
for (int i = 0; i < n; i++) cin >> p[i] >> c[i];
for (int i = 0; i < n; i++)
if (c[i] > p[i]) {
flag = 1;
break;
}
for (int i = 1; i < n; i++) {
if (c[i] - c[i - 1] > p[i] - p[i - 1] || p[i] < p[i - 1] ||
c[i] < c[i - 1]) {
flag = 1;
break;
}
}
if (flag)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i2 = pair<int, int>;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
int pp = 0, pc = 0;
bool ok = true;
for (int i = 1; i <= n; i++) {
int np, nc;
cin >> np >> nc;
if (np - pp < nc - pc || nc - pc < 0) ok = false;
pp = np;
pc = nc;
}
cout << (ok ? "YES\n" : "NO\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int prp, prc;
cin >> prp >> prc;
bool flag = false;
if (prp < prc) {
flag = true;
}
for (int i = 1; i < n; i++) {
int p, c;
cin >> p >> c;
if (p < prp || c < prc) {
flag = true;
}
if (p < c) {
flag = true;
}
if (abs(prp - p) < abs(prc - c)) {
flag = true;
}
prp = p;
prc = c;
}
if (flag) {
cout << "NO\n";
} else {
cout << "YES\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int k;
cin >> k;
bool ok = true;
int pa = 0, pb = 0;
for (int j = 0; j < k; ++j) {
int a, b;
cin >> a >> b;
if (a < pa || b < pb) ok = false;
if (a == pa && b != pb) ok = false;
if (a > pa && (a - pa) < (b - pb)) ok = false;
pa = a;
pb = b;
}
cout << (ok ? "YES" : "NO") << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
void input(long long int n, long long int a[]) {
for (long long int i = 0; i < n; ++i) cin >> a[i];
}
long long int bin_expo(long long int A, long long int B, long long int M) {
long long int result = 1ll;
while (B > 0) {
if (B % 2 == 1) {
result = (result * A) % M;
}
A = (A * A) % M;
B = B / 2;
}
return result;
}
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
return (a * b) / gcd(a, b);
}
int main() {
ios_base::sync_with_stdio(0);
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
pair<long long int, long long int> pa[n];
for (long long int i = 0; i < n; ++i) cin >> pa[i].first >> pa[i].second;
long long int flag = 0;
for (long long int i = 0; i < n; ++i) {
if (pa[i].first < pa[i].second) {
flag = 1;
break;
}
}
for (int i = 1; i < n; i++) {
long long int tot_plays = pa[i].first - pa[i - 1].first;
long long int tot_score = pa[i].second - pa[i - 1].second;
if (tot_plays >= 0 && tot_score >= 0 && tot_score <= tot_plays) continue;
flag = 1;
break;
}
if (flag)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using ll = long int;
using namespace std;
ll m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t, x, a, b, q, r, f, l, h;
cin >> t;
while (t--) {
ll n;
q = 0;
cin >> n;
int bl = 1;
r = 0;
ll p[n], c[n];
h = 0;
for (ll i = 0; i < n; i++) {
cin >> p[i] >> c[i];
}
for (ll i = 0; i < n; i++) {
a = p[i];
b = c[i];
if (b >= r and a >= q and a - h >= b and a >= b) {
h = a - b;
q = a;
r = b;
} else
bl = 0;
}
if (bl == 1)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
int n, m, t;
int v[MAXN];
char s[MAXN];
int main() {
cin >> t;
while (t--) {
cin >> n;
int a, b;
cin >> a >> b;
int flag = a >= b;
for (int i = 1; i <= n - 1; i++) {
int tmpa, tmpb;
cin >> tmpa >> tmpb;
if (tmpa < a || tmpb < b || tmpb - b > tmpa - a) flag = 0;
a = tmpa, b = tmpb;
}
if (flag)
cout << "YES";
else
cout << "NO";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long t, a, b, c, n, lasta = -1, lastb = -1;
bool ok = 1;
int main() {
ios_base::sync_with_stdio(0);
cin.tie();
cout.tie();
cin >> t;
while (t--) {
ok = 1;
cin >> n;
lasta = -1, lastb = -1;
for (long long i = 0; i < n; i++) {
cin >> a >> b;
if (lasta == -1 and lastb == -1) {
lasta = a;
lastb = b;
}
if (lasta <= a and lastb <= b and a >= b and (a - lasta) >= (b - lastb)) {
lasta = a;
lastb = b;
} else {
ok = 0;
}
}
if (ok)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, n, m, j, k, t, p, c, nowp, nowc;
bool flag = true;
scanf("%d", &t);
while (t--) {
flag = true;
nowp = nowc = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d%d", &p, &c);
if (!flag) continue;
if (p >= nowp && c >= nowc) {
if (p - nowp < c - nowc) {
flag = false;
}
if (nowp < p) nowp = p;
if (nowc < c) nowc = c;
} else {
flag = false;
}
}
if (flag)
printf("YES\n");
else
printf("NO\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t-- > 0) {
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
for (int i = 0; i < n; i++) {
cin >> a[i] >> b[i];
}
int i = 0;
int val1 = a[i], val2 = b[i];
if (val1 < val2) {
cout << "NO" << endl;
continue;
}
for (i = 1; i < n; i++) {
if ((a[i] < b[i]) or (a[i] < val1) or (b[i] < val2) or
(a[i] - val1 < b[i] - val2)) {
break;
cout << "hahahah" << endl;
} else {
val1 = a[i], val2 = b[i];
}
}
if (i != n) {
cout << "NO";
} else {
cout << "YES";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n, i, a, b;
cin >> t;
while (t--) {
cin >> n;
bool f = false;
vector<long long int> p(n), c(n);
for (i = 0; i < n; i++) {
cin >> a >> b;
p[i] = a, c[i] = b;
}
for (i = 1; i < n; i++) {
if (p[i] < p[i - 1]) {
f = true;
cout << "NO"
<< "\n";
break;
}
if (c[i] < c[i - 1]) {
f = true;
cout << "NO"
<< "\n";
break;
}
}
if (!f) {
for (i = 0; i < n; i++) {
if (c[i] > p[i]) {
f = true;
cout << "NO"
<< "\n";
break;
}
}
}
if (!f) {
for (i = 0; i < n - 1; i++) {
if (c[i + 1] - c[i] > p[i + 1] - p[i]) {
f = true;
cout << "NO"
<< "\n";
break;
}
}
}
if (!f)
cout << "YES"
<< "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, t;
cin >> t;
while (t--) {
cin >> n;
vector<pair<int, int>> a(n);
for (int i = 0; i < (int)n; i++) cin >> a[i].first >> a[i].second;
bool ok = 1;
if (n == 1 && (a[0].first < a[0].second)) ok = 0;
for (int i = 0; i < (int)n - 1; i++) {
if (a[i + 1].first - a[i].first < a[i + 1].second - a[i].second) ok = 0;
if (a[i + 1].second > a[i].second) {
if (a[i + 1].first <= a[i].first) ok = 0;
} else if (a[i + 1].second < a[i].second)
ok = 0;
if (a[i + 1].first < a[i].first) ok = 0;
if (a[i].first < a[i].second) ok = 0;
}
cout << (ok ? "YES\n" : "NO\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n, flag = 1;
cin >> n;
long long p[n + 1], c[n + 1];
long long diff1 = 0, diff2 = 0;
for (long long i = 1; i <= n; i++) {
cin >> p[i] >> c[i];
}
for (long long i = 1; i <= n; i++) {
diff1 = p[i] - diff1;
diff2 = c[i] - diff2;
if (diff1 < diff2 || diff1 < 0 || diff2 < 0) {
flag = 0;
break;
}
diff1 = p[i];
diff2 = c[i];
}
if (flag == 1)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, x = 0, y = 0, p = 0, q = 0;
cin >> n;
bool ans = true;
for (int i = 1; i <= n; i++) {
cin >> p >> q;
if (p < x || q < y)
ans = false;
else if (q - y > p - x)
ans = false;
x = p;
y = q;
}
if (ans == true)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long p, c, lp, lc;
long long pos = 0;
for (long long i = 0; i < n; i++) {
cin >> p >> c;
if (i > 0) {
if (p < c) {
pos = 1;
continue;
}
if (c < lc) {
pos = 1;
continue;
}
if (p < lp) {
pos = 1;
continue;
}
if (c - lc > p - lp) {
pos = 1;
}
}
if (i == 0) {
if (p < c) {
pos = 1;
continue;
}
}
lc = c;
lp = p;
}
if (pos)
cout << "NO\n";
else
cout << "YES\n";
}
}
|
#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 a, b;
long long int c = 0, d = 0;
bool f = true;
for (long long int i = 0; i < n; i++) {
cin >> a >> b;
if (a < c || b < d || a - c < b - d) f = false;
c = a, d = b;
}
if (f)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int num;
cin >> num;
int min1 = -1, min2 = -1;
int temp1, temp2;
bool val = true;
for (int i = 0; i < num; i++) {
cin >> temp1 >> temp2;
int avoid = ((temp1 - min1) - (temp2 - min2));
if (i != 0) {
if (temp1 < min1 || temp2 < min2 || avoid < 0) {
val = false;
}
}
if (temp2 > temp1) val = false;
min1 = temp1;
min2 = temp2;
}
if (val)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long double PI = 4 * atan((long double)1);
long long int get_hash(string s) {
long long int N = 1000001;
long long int base[N], A = 11, MD = 1110111110111;
base[0] = 1;
for (int i = (1); i < (N); ++i) base[i] = (base[i - 1] * A) % MD;
long long int hs = 0;
for (int i = (0); i < (s.size()); ++i) {
hs += (s[i] * base[i]);
hs %= MD;
}
return hs;
}
long long power(long long a, long long n) {
long long res = 1;
while (n) {
if (n % 2) res *= a;
a *= a;
n /= 2;
}
return res;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int e = 0;
long long int x[n], y[n];
for (int i = (0); i < (n); ++i) {
cin >> x[i] >> y[i];
if (x[i] < y[i]) {
e = 1;
}
}
if (e == 1) {
cout << "NO\n";
continue;
}
long long int a[n - 1], b[n - 1];
for (int i = (1); i < (n); ++i) {
a[i - 1] = x[i] - x[i - 1];
b[i - 1] = y[i] - y[i - 1];
}
for (int i = (0); i < (n - 1); ++i) {
if (a[i] < 0 || b[i] < 0) {
e = 1;
break;
}
if (b[i] > a[i]) {
e = 1;
break;
}
}
if (e == 1)
cout << "NO";
else
cout << "YES";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int t, n;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> t;
while (t--) {
cin >> n;
int lp = 0, lc = 0;
int pi, ci;
bool poss = true;
for (int i = 0; i < n; i++) {
cin >> pi >> ci;
if (ci - lc > pi - lp) {
poss = false;
}
if (lc > ci || lp > pi) {
poss = false;
}
lc = ci;
lp = pi;
}
if (poss) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long q, n;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> q;
while (q--) {
cin >> n;
long long p = 0, c = 0;
long long ap, ac;
bool t = 1;
for (long long i = 0; i < n; ++i) {
cin >> ap >> ac;
if (ap < ac) t = 0;
if ((ap < p) || (ac < c)) t = 0;
if ((ap - p) < (ac - c)) t = 0;
p = ap;
c = ac;
}
cout << (t ? "YES" : "NO") << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int testcases;
cin >> testcases;
while (testcases--) {
int n, flag = 0;
cin >> n;
int x[n], y[n];
cin >> x[0] >> y[0];
if (y[0] > x[0]) {
flag = 1;
}
for (int i = 1; i < n; ++i) {
cin >> x[i] >> y[i];
if ((x[i] < x[i - 1]) or (y[i] < y[i - 1]) or
((y[i] - y[i - 1]) > (x[i] - x[i - 1]))) {
flag = 1;
}
}
if (flag) {
cout << "NO\n";
} else {
cout << "YES\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, i, j, a, a1, b, b1, f = 0;
cin >> t;
for (i = 0; i < t; i++) {
cin >> n;
cin >> a1 >> b1;
if (a1 < b1) {
f++;
}
for (j = 1; j < n; j++) {
cin >> a >> b;
if (a < b || a - a1 < b - b1) {
f++;
} else if ((a > a1 && b >= b1) || (a == a1 && b == b1)) {
a1 = a;
b1 = b;
} else {
f++;
}
}
if (f == 0) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
f = 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int M = 100005;
long long int N = 1e9 + 7;
long long int Z = 998244353;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
void precompute() {}
int max3(int x, int y, int z) { return max(x, max(y, z)); }
long long int power(long long int x, unsigned int y, int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
long long int modinv(long long int x, int p) { return (power(x, p - 2, p)); }
bool compare(const pair<int, int> &p1, const pair<int, int> &p2) {
return (p1.first > p2.first);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
precompute();
while (t--) {
int n, x = 0, y = 0, prevx = 0, prevy = 0;
cin >> n;
int flag = 0;
for (int i = 0; i < n; i++) {
cin >> x >> y;
if (((x - prevx) >= 0) && ((y - prevy) >= 0) &&
(y - prevy) <= (x - prevx)) {
} else {
flag = 1;
}
prevx = x;
prevy = y;
}
if (flag == 1) {
cout << "NO\n";
} else {
cout << "YES\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();
constexpr double PI = 3.1415926535897932384626433832795028841971;
void solve() {
int Q;
cin >> Q;
cout << setprecision(20);
while (Q--) {
double N;
cin >> N;
double phi = 0;
ll cnt = 0;
while (phi < PI / 4.0) {
phi += PI / N;
++cnt;
}
double z = PI / (2.0 * N) + PI / N * (N / 2 - cnt);
double th = PI / 4.0 - z;
double ans = cos(th) / sin(PI / (2.0 * N));
cout << ans << "\n";
}
}
int main() {
cin.tie(0), cout.tie(0);
ios::sync_with_stdio(false);
solve();
cout << flush;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct edge {
int t, f, w;
bool operator<(const edge& e) const { return w > e.w; }
edge(int from, int to, int weight) {
t = to;
f = from;
w = weight;
}
};
const double EPS = (1e-5);
struct line {
double a, b, c;
};
struct point {
double x, y;
point() { x = y = 0.0; }
point(double _x, double _y) : x(_x), y(_y) {}
bool operator==(point other) const {
return (fabs(x - other.x) < EPS && (fabs(y - other.y) < EPS));
}
};
double dist(point p1, point p2) {
return fabs(p1.x - p2.x) * fabs(p1.x - p2.x) +
fabs(p1.y - p2.y) * fabs(p1.y - p2.y);
}
void pointsToLine(point p1, point p2, line& l) {
if (fabs(p1.x - p2.x) < EPS) {
l.a = 1.0;
l.b = 0.0;
l.c = -p1.x;
} else {
l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x);
l.b = 1.0;
l.c = -(double)(l.a * p1.x) - p1.y;
}
}
bool areParallel(line l1, line l2) {
return (fabs(l1.a - l2.a) < EPS) && (fabs(l1.b - l2.b) < EPS);
}
bool areSame(line l1, line l2) {
return areParallel(l1, l2) && (fabs(l1.c - l2.c) < EPS);
}
bool areIntersect(line l1, line l2, point& p) {
if (areParallel(l1, l2)) return false;
p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
if (fabs(l1.b) > EPS)
p.y = -(l1.a * p.x + l1.c);
else
p.y = -(l2.a * p.x + l2.c);
return true;
}
long long binpowmod(long long a, long long b, long long m) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
long long binpow(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
int findXOR(int n) {
switch (n % 4) {
case 0:
return n;
case 1:
return 1;
case 2:
return n + 1;
case 3:
return 0;
}
}
int rangeXOR(int l, int r) { return (findXOR(l - 1) ^ findXOR(r)); }
int getbit(int mask, int bit) { return (mask & (1 << bit)); }
void setbit(int& mask, int bit, int val) {
if (val)
mask |= (1 << bit);
else
mask &= ~(1 << bit);
}
const int N = 1e5 + 10;
const int M = 2e5 + 10;
const long long INF = 9999999;
int BIT[N];
void update(int x, int val) {
++x;
while (x <= N) {
BIT[x] += val;
x += (x & -x);
}
}
int query(int x) {
++x;
int res = 0;
while (x > 0) {
res += BIT[x];
x -= (x & -x);
}
return res;
}
void solve() {
int n;
cin >> n;
cout << setprecision(10) << fixed << 1 / (2 * sin(acos(-1) / 4 / n)) << endl;
}
int main(void) {
int tc = 1;
cin >> tc;
while (tc--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
cout << fixed << setprecision(9)
<< cos(3.14159265358979323846 / (4 * n)) /
sin(3.14159265358979323846 / (2 * n))
<< "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
int tc;
cin >> tc;
while (tc--) {
double n;
cin >> n;
double pi = acos(-1.0);
n *= 2;
double angle = 360 / n;
angle /= 2;
double biglen = 0.5 / (sin(angle * pi / 180));
double ans = 1e9;
for (double i = 0; i <= angle * 2; i += 0.0001) {
double ans1, ans2;
ans1 = biglen * cos(i * pi / 180);
double a = 0.5 * i / angle;
ans2 = a / sin(i * pi / 180);
ans = min(ans, max(ans1, ans2));
}
cout << fixed << setprecision(9) << ans * 2 << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
void fastio() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed;
cout.precision(9);
}
int main() {
fastio();
int t;
cin >> t;
while (t--) {
double n;
cin >> n;
n *= 2;
double angle = (3.141592653589793 - 2 * 3.141592653589793 / n) / 2;
double ans = sin(3.141592653589793 / 2 * (n - 1) / n) * 1 /
(sin(3.141592653589793 / n));
cout << ans << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool comp(int x, int y) { return x > y; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int t = 1;
cin >> t;
while (t--) {
double n;
cin >> n;
cout << fixed << setprecision(9)
<< cos(3.1415926535 / (4 * n)) / sin(3.1415926535 / (2 * n)) << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
double sides[405];
int main() {
std::cout << std::fixed;
std::cout << std::setprecision(10);
double theta = 0;
for (int i = 2; i < 405; i++) {
sides[i] = cos(2 * acos(0) / (i * 2)) / sin(2 * acos(0) / (i));
}
int T;
int n;
cin >> T;
while (T--) {
cin >> n;
n = n << 1;
cout << sides[n] << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
double x = (3.14159265358979323846 / (double)n);
double r = 0.5 / cos((3.14159265358979323846 - x) / 2.0);
double ans = r * sin((3.14159265358979323846 - x) / 2.0 + x / 4.0) * 2.0;
cout << fixed << setprecision(9) << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MODA = 1000000007;
long long int ncr(long long int, long long int);
long long int power(long long int, long long int);
long long int modi(long long int);
long long int powm(long long int, unsigned int);
long long int gcd(long long int, long long int);
long long int kadane(long long int[], long long int);
bool isPrime(long long int);
bool isPowerTwo(long long int);
bool isSubstring(string, string);
void generateFactors(long long int);
void generatePrimeFactors(long long int);
void facto(long long int);
void SieveOfEratosthenes(long long int);
void mo_dfs(long long int, long long int);
long long int fact[1025] = {};
bool prime[105];
long long int timer;
long long int S[100], T[100], FT[200];
vector<int> ADJ[100];
vector<long long int> factors;
vector<long long int> primefactors;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int tc = 1;
cin >> tc;
while (tc--) {
int n;
cin >> n;
cout << fixed << setprecision(10)
<< cos(3.1415926535897932384626433832795 / (4 * n)) /
sin(3.1415926535897932384626433832795 / (2 * n))
<< "\n";
}
return 0;
}
void facto(long long int n) {
fact[0] = 1;
for (int i = 1; i <= n; i++) fact[i] = (i * 1ll * fact[i - 1]) % MODA;
}
long long int power(long long int a, long long int b) {
long long int res = 1;
while (b) {
if (b & 1) res = (res * a) % MODA;
a = (a * a) % MODA;
b >>= 1;
}
return res;
}
long long int modi(long long int a) { return powm(a, MODA - 2); }
long long int powm(long long int x, unsigned int y) {
if (y == 0) return 1;
long long int p = power(x, y / 2) % MODA;
p = (p * p) % MODA;
return (y % 2 == 0) ? p : (x * p) % MODA;
}
long long int gcd(long long int a, long long int b) {
if (a == 0) return b;
return gcd(b % a, a);
}
bool isPowerTwo(long long int x) { return (x && !(x & (x - 1))); }
long long int kadane(long long int a[], long long int size) {
long long int max_so_far = INT_MIN, max_ending_here = 0;
for (long long int i = 0; i < size; i++) {
max_ending_here = max_ending_here + a[i];
if (max_so_far < max_ending_here) max_so_far = max_ending_here;
if (max_ending_here < 0) max_ending_here = 0;
}
return max_so_far;
}
void generateFactors(long long int n) {
factors.clear();
for (long long int i = 2; i * i <= n; i++) {
if (n % i == 0) {
factors.push_back(i);
if (n / i != i) factors.push_back(n / i);
}
}
factors.push_back(1);
factors.push_back(n);
sort(factors.begin(), factors.end());
}
void generatePrimeFactors(long long int n) {
primefactors.clear();
for (long long int i = 2; i * i <= n; i++) {
if (n % i == 0) {
primefactors.push_back(i);
while (n % i == 0) n = n / i;
}
}
if (n != 1) primefactors.push_back(n);
}
void SieveOfEratosthenes(long long int n) {
memset(prime, true, sizeof(prime));
for (long long int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (long long int i = p * p; i <= n; i += p) prime[i] = false;
}
}
}
long long int ncr(long long int n, long long int r) {
if (r == 0) return 1;
fact[0] = 1;
for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % MODA;
return (fact[n] * modi(fact[r]) % MODA * modi(fact[n - r]) % MODA) % MODA;
}
bool isPrime(long long int n) {
if (n < 2) return false;
for (long long int i = 2; i * i <= n; i++)
if (n % i == 0) return false;
return true;
}
void mo_dfs(long long int node, long long int parent) {
S[node] = timer;
FT[timer] = node;
timer++;
for (long long int child : ADJ[node]) {
if (child != parent) mo_dfs(child, node);
}
T[node] = timer;
FT[timer] = node;
timer++;
}
bool isSubstring(string s1, string s2) {
if (s1.find(s2) != string::npos)
return true;
else
return false;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long double res = 0;
long double pi = 3.14159265;
res = 1.0 / (2 * sin(pi / (4.0 * n)));
cout << setprecision(9) << res << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265;
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
cout << fixed << setprecision(7) << (cos(PI / (4 * n)) / sin(PI / (2 * n)))
<< endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int t;
scanf("%d\n", &t);
for (int itr = 0; itr < t; ++itr) {
int n;
scanf("%d", &n);
double len_1 = 1.0, len_2 = 0.0;
double b_angle = 3.14159265359 / (double)n;
double angle = b_angle;
for (int i = 0; i < n / 2; ++i) {
len_1 += 2.0 * cos(angle);
len_2 += 2.0 * sin(angle);
angle += b_angle;
}
double th = 3.14159265359 / 4.0, low = 0.0, high = 3.14159265359 / 2.0;
double a = len_1 * cos(th), b = len_2 * cos(th) + sin(th);
while (fabs(a - b) > 0.0000000001) {
if (a > b) {
low = th;
} else {
high = th;
}
th = (low + high) / 2.0;
a = len_1 * cos(th), b = len_2 * cos(th) + sin(th);
}
printf("%lf\n", a);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t, n;
long double size, theta, theta1, theta2, x, y, r;
cin >> t;
while (t--) {
cin >> n;
theta = M_PI / n;
r = 1 / (2 * sin(theta / 2));
theta1 = (M_PI * floor(n / 2)) / n;
theta2 = M_PI - theta1;
x = r * (sin(theta1 / 2));
y = r * (sin(theta2 / 2));
cout << fixed << setprecision(9) << (x + y) * sqrt(2) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 9e18;
const long double pi = 2 * acos(0.0);
long long int t, n;
long double ans, angle, diff, dis, l, r;
bool check(long double l, long double r) {
if (abs(r - l) <= (1.0 / 1.0e9)) {
return false;
} else {
return true;
}
}
void solve() {
cin >> n;
angle = pi / n;
diff = 1.0 / 1.0e5;
dis = sin(pi / (2 * n));
ans = 2.0 * (sin((pi - angle) / 2.0) / (sin(angle)));
l = 0.000000, r = angle;
while (check(l, r)) {
long double r1 = r * 1e6;
long double l1 = l * 1e6;
long double mid1 = ((2.0 * l1) + r1) / 3.0;
long double mid2 = (l1 + (2.0 * r1)) / 3.0;
mid1 /= 1.0e6;
mid2 /= 1.0e6;
long double x_left = 1.0e+99, x_right = -1.0e+99, y_left = 1.0e+99,
y_right = -1.0e+99;
for (long double j = 0; j < (2.0 * n); j += 1.0) {
long double px = cos(((pi * j) / n) + mid1);
long double py = sin(((pi * j) / n) + mid1);
x_left = min(x_left, px);
x_right = max(x_right, px);
y_left = min(y_left, py);
y_right = max(y_right, py);
}
long double ans1 = (max(x_right - x_left, y_right - y_left) / dis) / 2.0;
x_left = 1.0e+99, x_right = -1.0e+99, y_left = 1.0e+99, y_right = -1.0e+99;
for (long double j = 0; j < (2.0 * n); j += 1.0) {
long double px = cos(((pi * j) / n) + mid2);
long double py = sin(((pi * j) / n) + mid2);
x_left = min(x_left, px);
x_right = max(x_right, px);
y_left = min(y_left, py);
y_right = max(y_right, py);
}
long double ans2 = (max(x_right - x_left, y_right - y_left) / dis) / 2.0;
if (ans1 <= ans2) {
r = mid2;
} else {
l = mid1;
}
ans = min(ans, min(ans1, ans2));
}
cout << fixed << setprecision(9) << ans << "\n";
}
int32_t main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
double dist(double x1, double y1, double x2, double y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
n *= 2;
double angle = 2 * acos(-1.0) / n, lo = 0.0, hi = angle / 2;
double xtop = cos((n / 4 + 1) * angle), ytop = sin((n / 4 + 1) * angle);
double x0 = 1.0, y0 = 0.0;
double x1 = -1.0, y1 = 0.0;
while (hi - lo > 1e-12) {
double m1 = tan((hi + lo) / 2), m2 = -1 / m1;
double xm = (m1 * xtop - ytop - m2 * x0 + y0) / (m1 - m2);
double ym = m1 * xm - m1 * xtop + ytop;
double xn = (m1 * xtop - ytop - m2 * x1 + y1) / (m1 - m2);
double yn = m1 * xn - m1 * xtop + ytop;
double xp = -xn, yp = -yn;
double mn = dist(xm, ym, xn, yn), mp = dist(xm, ym, xp, yp);
if (mn > mp)
lo = (hi + lo) / 2;
else
hi = (hi + lo) / 2;
}
double m1 = tan((hi + lo) / 2), m2 = -1 / m1;
double xm = (m1 * xtop - ytop - m2 * x0 + y0) / (m1 - m2);
double ym = m1 * xm - m1 * xtop + ytop;
double xn = (m1 * xtop - ytop - m2 * x1 + y1) / (m1 - m2);
double yn = m1 * xn - m1 * xtop + ytop;
double mn = dist(xm, ym, xn, yn);
printf("%.9lf\n", mn / dist(x0, y0, cos(angle), sin(angle)));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
cout << fixed << setprecision(10) << cos(pi / (4 * n)) / sin(pi / (n * 2))
<< '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
const long long big = 998244353;
using namespace std;
long long power(long long a, long long n) {
if (n == 0) return 1;
if (n % 2 == 1)
return (power(a, n - 1) * a) % big;
else {
long long b = power(a, n / 2);
return (b * b) % big;
}
}
void solve() {
int n;
cin >> n;
double k = n;
cout.precision(10);
double r = 1 / sin(acos(-1) / (2 * k));
double a = 2 * r * r * (1 - cos(acos(-1) / k * (k - 1) / 2));
double b = 2 * r * r * (1 - cos(acos(-1) / k * (k + 1) / 2));
cout << (sqrt(a / 2) + sqrt(b / 2)) / 2 << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t = 1;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, mod = 1000000007;
const double pi = 3.1415926535897932, eps = 1e-6;
void chmax(int &x, int y) {
if (x < y) x = y;
}
void chmin(int &x, int y) {
if (x > y) x = y;
}
int T, n;
void solve() {
scanf("%d", &n);
double deg = 360.0 / (n + n);
double ans = 0;
for (int(i) = (1); (i) <= (n / 2); (i)++) {
double S = sin((deg * i - deg / 2.0) / 180.0 * pi);
ans += S;
}
double ans1 = 2 * ans + 1.0;
double rotate = deg / 4.0;
ans1 = ans1 * cos(rotate / 180.0 * pi);
printf("%.12lf\n", ans1);
}
int main() {
scanf("%d", &T);
while (T--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double solvre(int n) {
double ans = 0;
ans += 1;
double del = 3.14159265358979 / (n);
double ang = del;
while (ang < (3.14159265358979 / 2) - 10e-9) {
ans += 2 * cos(ang);
ang += del;
}
return ans * cos(del / 4);
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
scanf("%d", &n);
printf("%.10lf\n", solvre(n));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
return a * (b / gcd(a, b));
}
void solve() {
double pi = atan(1) * 4;
cout << setprecision(15);
long long int n;
cin >> n;
double ans = 1 / (1.0 * sin(pi / (2.0 * n)));
double temp = cos(pi / (4.0 * n));
cout << ans * temp << '\n';
}
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
long long int TESTS = 1;
cin >> TESTS;
while (TESTS--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 998244353;
long long int mod = 1e9 + 7;
long long int INF = 1e18;
long long int dx[] = {1, -1, 0, 0};
long long int dy[] = {0, 0, 1, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
double p = 3.14159265358979;
double ans = 0.0;
ans = sin(p / (4 * n));
ans = 1.0 / ans;
ans = ans * 0.5;
cout << setprecision(15) << ans << endl;
;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long double t;
cin >> t;
while (t--) {
long double n;
cin >> n;
long double res1 = cos(3.1415926535 / (4 * n));
long double res2 = sin(3.1415926535 / (2 * n));
cout << fixed << setprecision(10);
cout << res1 / res2 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
const double pi = acos(-1.0);
using namespace std;
long long int gcd(long long int a, long long int b) {
return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
return a * b / gcd(a, b);
}
double answer(long long int n) {
double pro;
if (n % 4 == 0) {
pro = pi * (180.0 / n) / 180;
} else {
pro = pi * (180.0 / (2 * n)) / 180;
}
double x = 1.0e+99, x1 = -1.0e+99, y = 1.0e+99, y1 = -1.0e+99;
for (long long int i = 0; i < n; i++) {
double px = cos(2 * pi * i / n + pro);
double py = sin(2 * pi * i / n + pro);
x = min(x, px);
x1 = max(x1, px);
y = min(y, py);
y1 = max(y1, py);
}
double res = max(x1 - x, y1 - y);
double ans = res / sin(pi / n) / 2;
return ans;
}
void solve() {
long long int n;
cin >> n;
n = n * 2;
cout << fixed << setprecision(10);
cout << answer(n) << endl;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
int tc = 1;
while (t--) {
solve();
tc++;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int TESTS = 1;
cin >> TESTS;
while (TESTS--) {
long long n;
cin >> n;
double x = 3.1415926535897932 / (2 * n);
double t = tan(x);
double p = sin(x);
double ans = n * 4;
;
double dia = 1 / p;
long long i = n / 2;
double k = dia * (sin(i * x) + sin((n - i) * x)) / sqrt(2);
ans = min(ans, k);
cout << setprecision(20) << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double side_len(double radius, double angle) {
return 2.0 * radius * sin(M_PI * angle / (2 * 180));
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
double n;
double ans;
cin >> n;
double radius = 1.0 / (2.0 * sin(M_PI / (2 * n)));
double angle = 180 / n;
double l = side_len(radius, (n - 1) / 2 * angle);
double r = side_len(radius, (n + 1) / 2 * angle);
cout << fixed << setprecision(9) << (l * M_SQRT1_2) + (r * M_SQRT1_2)
<< "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double sn(double a) {
double param, result;
param = a;
result = sin(param * 3.14159265 / 180.0);
return result;
}
int Q;
int main() {
cin >> Q;
while (Q--) {
double n;
cin >> n;
double e = (180 * (2 * n - 2)) / (n * 2);
double a = (180 * (2 * n - 2)) / (n * 2);
double p1 = 0, p2 = 0;
double n1 = (int)n / 2;
double n2 = n - n1;
if ((int)n1 % 2 == 1) {
p1++;
n1--;
a = a - 90;
} else
a = a / 2;
for (double k = 2; k <= n1; k += 2) {
p1 += 2 * (sn(a));
a = e - (90 - a) - 90;
}
e = (180 * (2 * n - 2)) / (n * 2);
a = (180 * (2 * n - 2)) / (n * 2);
if ((int)n2 % 2 == 1) {
p2++;
n2--;
a = a - 90;
} else
a = a / 2;
for (double k = 2; k <= n2; k += 2) {
p2 += (double)2.0 * (sn(a));
a = e - (90.0 - a) - 90.0;
}
p1 = p1 * (sqrt(2)) / 2;
p2 = p2 * (sqrt(2)) / 2;
cout << fixed;
cout << setprecision(6) << (double)(p1 + p2) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
double nGon(int N) {
double proAngleVar;
if (N % 4 == 0) {
proAngleVar = pi * (180.0 / N) / 180;
} else {
proAngleVar = pi * (180.0 / (2 * N)) / 180;
}
double negX = 1.0e+99, posX = -1.0e+99, negY = 1.0e+99, posY = -1.0e+99;
for (int j = 0; j < N; ++j) {
double px = cos(2 * pi * j / N + proAngleVar);
double py = sin(2 * pi * j / N + proAngleVar);
negX = min(negX, px);
posX = max(posX, px);
negY = min(negY, py);
posY = max(posY, py);
}
double opt2 = max(posX - negX, posY - negY);
return (double)opt2 / sin(pi / N) / 2;
}
int main() {
int test, i, j, k, n;
cin >> test;
while (test--) {
cin >> n;
cout << fixed << setprecision(6);
cout << nGon(2 * n) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tos(T a) {
stringstream ss;
string ret;
ss << a;
ss >> ret;
return ret;
}
void read(int &_a) { int temp = scanf("%d", &_a); }
void read(int &_a, int &_b) { int temp = scanf("%d %d", &_a, &_b); }
void read(int &_a, int &_b, int &_c) {
int temp = scanf("%d %d %d", &_a, &_b, &_c);
}
int main() {
int T;
read(T);
double n;
while (T--) {
cin >> n;
double ang = 3.141592653589793238 / (4.0 * n);
double l = 0.5 / sin(ang);
printf("%.10lf\n", l);
}
return 0;
}
|
#include <bits/stdc++.h>
std::mt19937 rng(
(int)std::chrono::steady_clock::now().time_since_epoch().count());
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int t;
std::cin >> t;
std::cout << std::fixed << std::setprecision(10);
while (t--) {
int n;
std::cin >> n;
n *= 2;
std::cout << (1.0 / sin(acos(-1) / n / 2)) / 2 << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, t;
double pi = 3.1415926535897932;
cin >> t;
while (t--) {
cin >> n;
if (n % 2)
cout << setprecision(16) << fixed << cos(pi / (4 * n)) / sin(pi / (2 * n))
<< '\n';
else
cout << setprecision(16) << fixed << 1 / tan(pi / (n * 2)) << '\n';
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const double pi = acos(-1);
const double sq2 = sqrt(2);
void solve() {
int n;
cin >> n;
double tt = pi / n, k = 1.0 / 2 / sin(tt / 2);
double a = n / 2, b = n - a;
cout << setiosflags(ios::fixed) << setprecision(9)
<< k * (sqrt(1 - cos(tt * a)) + sqrt(1 - cos(tt * b))) << '\n';
}
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
const long long inf = 1 << 28;
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
cout << std::fixed << std::setprecision(9)
<< (cos(3.14159265358979323846 / (4 * n)) /
sin(3.14159265358979323846 / (2 * n)))
<< endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
double pi = acos(-1);
while (t--) {
int n;
cin >> n;
float temp = 0;
int i = 1;
cout << fixed << setprecision(9) << cos(pi / (4 * n)) / sin(pi / (2 * n))
<< endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ini() {
int x;
scanf("%d", &x);
return x;
}
long long inl() {
long long x;
scanf("%lld", &x);
return x;
}
int main() {
int t = ini();
while (t--) {
long double x, ang;
cin >> x;
ang = 360 / (x * 4);
ang = ang * acos(-1) / 180.0;
long double ans1 = 0.25 / sin(ang * 0.5);
ans1 *= 2.0;
printf("%0.9Lf\n", ans1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n;
cin >> n;
const long double pi = 3.14159265359;
long double deg = 180 * 1.0 / n;
long double rad = (pi * 1.0) / n;
long double tans = tan(rad);
tans = 1 / tans;
long double res = cos(pi / (4 * n)) / sin(pi / (2 * n));
cout << res << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
if (fopen("input.txt", "r")) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
cout << setprecision(20);
long long t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
double ans;
if (n & 1) {
ans = cos(0.78539816339744830962 / n) / sin(1.57079632679489661923 / n);
} else {
ans = 1.0 / tan(1.57079632679489661923 / n);
}
printf("%.9f\n", ans);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t, n;
cin >> t;
while (t--) {
cin >> n;
double ans = .5 / sin(3.14159265358979323846 / (4 * n));
cout.precision(8);
cout << fixed << ans << endl;
}
}
|
#include <bits/stdc++.h>
int T;
int n;
int Max(int a, int b) { return a > b ? a : b; }
int Min(int a, int b) { return a < b ? a : b; }
int Abs(int a) { return a < 0 ? -a : a; }
const double PI = 3.1415926535897932;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
if (!(n & 1)) {
double a = (180.0 - (180.0 / (double)n)) / 2.0;
double ans = 0.5 * tan(PI / 180 * a);
printf("%.9lf\n", ans * 2.0);
} else {
double x = (PI / 4.0) / n;
double ans1 = 0, ans2 = 0;
double _x = x;
for (int i = 1; i <= n; ++i) ans1 += sin(_x), _x += PI / n;
_x = x;
for (int i = 1; i < n; ++i) ans2 += cos(_x), _x += PI / n;
printf("%.9lf\n", ans1 > ans2 ? ans1 : ans2);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int T, n;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
double ct = pi / (double)n;
double cct = (double)round((double)n / 4.0) * ct;
double x = 0.5 / sin(0.5 * ct);
double ans1 = (sin(cct) * x / (sin(pi / 4.0)));
double ans2 = (sin(pi / 2.0 - cct) * x / sin((pi / 4.0)));
printf("%.9f\n", ans1 + ans2);
}
return 0;
}
|
#include <bits/stdc++.h>
const double PI = acos(-1.0);
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n;
scanf("%d", &n);
printf("%.12lf\n", cos(PI / 4.0 / n) / sin(PI / 2.0 / n));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t) {
int n;
cin >> n;
double pi = 2 * asin(1);
double area = cos(pi / (4 * n)) / sin(pi / (2 * n));
printf("%0.15f\n", area);
t--;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n;
cin >> t;
while (t--) {
cin >> n;
n *= 2;
float theta = (float)180 / n;
float den = sin(theta * 3.141592653 / 180);
den = 1 / den;
int i = 1;
float ang;
ang = 3 * (float)90 / n;
ang = 90 + theta - ang;
float num = sin(ang * 3.141592653 / 180);
printf("%0.9f\n", num * den);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout.precision(10);
double PI = acos(-1.0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
printf("%.9f\n", (cos(PI / (4.0 * n)) / sin(PI / (2.0 * n))));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void zz() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const double pi = 3.1415926535897932;
double polydiagonal(double n, double a) {
if (a < 0 && n < 0) return -1;
double rad = (pi / n);
return (double)(1 / sin(rad));
}
int32_t main() {
zz();
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
double x = pi / (4 * n);
double ans = sin(x) * 2;
ans = 1 / ans;
cout << fixed << setprecision(10) << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const double pi = 3.141592653589793;
double x, z, l;
long long T, y, n;
signed main() {
cin >> T;
while (T--) {
cin >> n;
x = 0;
z = pi / 2 / n;
l = 1.0 / 2 / sin(pi / 2 / n);
while (z <= pi / 2) x = max(x, l * 2 * (cos(z) + sin(z))), z += pi / n;
printf("%.9lf\n", x * sqrt(2) / 2);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
double n, i, j, ans;
cin >> n;
i = cos(3.14159265358979323846 / (4 * n));
j = sin(3.14159265358979323846 / (2 * n));
ans = i / j;
cout << fixed << setprecision(9) << ans << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 62;
const int MAX = 510000;
long long dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
long long dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const double pi = acos(-1);
const double eps = 1e-7;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
if (a > b) {
a = b;
return true;
} else
return false;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <typename T1, typename T2>
inline void print2(T1 a, T2 b) {
cout << a << " " << b << "\n";
}
template <typename T1, typename T2, typename T3>
inline void print3(T1 a, T2 b, T3 c) {
cout << a << " " << b << " " << c << endl;
}
const int mod = 998244353;
void solve() {
int n;
cin >> n;
double ans = 1.0 / sin(pi / (double)(2 * n)) * cos(pi / (double)n / 4.0);
printf("%.10f\n", ans);
}
int main() {
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int main() {
int t, n;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
double t1 = cos(pi / (4.0 * n));
double t2 = sin(pi / (2.0 * n));
double ans = t1 / t2;
printf("%.9f\n", ans);
}
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 *= 4;
cout << fixed << setprecision(9) << 0.5 / sin(pi / n);
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = 3.14159265358979323846;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
double n;
cin >> n;
double x = pi / n;
double r = ((1.0 / 2.0) * 1.0) * (1.0 / tan(x));
double R = cos(pi / (4.0 * n)) / sin(pi / (2.0 * n));
double dif = R + R - r - r;
dif /= 4.0;
cout << setprecision(12) << R << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int test;
cin >> test;
for (int t = 0; t < test; t++) {
int n;
cin >> n;
double ans = 0;
ans = cos(M_PI_4 / n) / (sin(M_PI_2 / n));
cout << setprecision(25) << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double T, n, i;
cin >> T;
while (T--) {
double par, len, val;
long long int N;
cin >> n;
n = 2 * n;
par = 3.14159265358979323846 / n;
len = 1 / sin(par);
N = (n / 2 - 1) / 2;
if (N % 2 == 0) {
N = N + 1;
N = N / 2;
val = par + (double)(N)*par * 2;
} else {
N = N + 1;
val = par + (double)(N / 2 - 1) * par * 2;
}
val = 3.14159265358979323846 / 2 - val;
val = val - 3.14159265358979323846 / 4;
i = cos(val) * len;
printf("%.10f\n", i);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
void solve() {
long long int n;
cin >> n;
double ans, pi = 3.14159265358979323846;
double rad = (2.0 * sin(pi / (2.0 * (double)n)));
ans = (cos(pi / (4.0 * n))) / sin(pi / (2.0 * (double)n));
cout << fixed << setprecision(15) << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
long long int t = 1;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
double x = n;
x = M_PI_2 / x;
double ans = sin((n / 2) * x + M_PI_4) / sin(x);
printf("%0.9lf\n", ans);
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 15;
const double PI = acos(-1);
struct Gauss {
long long n, f = 0;
double a[10][10], b[10];
void init(long long nn) {
n = nn;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) cin >> a[i][j];
cin >> b[i];
}
}
void solve() {
for (int i = 1; i <= n; i++) {
long long r = i;
for (int j = i + 1; j <= n; j++) {
if (fabs(a[j][i]) > fabs(a[r][i])) r = j;
}
if (r != i) {
for (int j = 1; j <= n; j++) swap(a[i][j], a[r][j]);
swap(b[i], b[r]);
}
if (abs(a[i][i] - 0.0) < 0.00001) {
cout << "No Solution" << endl;
f = 1;
return;
}
for (int j = 1; j <= n; j++) {
if (j == i) continue;
double d = 1.0 * a[j][i] / a[i][i];
for (int k = i; k <= n; k++) a[j][k] = a[j][k] - a[i][k] * d;
b[j] = b[j] - b[i] * d;
}
}
for (int i = 1; i <= n; i++) b[i] = 1.0 * b[i] / a[i][i];
}
void print() {
if (f == 1) return;
for (int i = 1; i <= n; i++) printf("%.2lf\n", b[i]);
}
};
long long n, m, p;
int num[N];
int main() {
int T;
cin >> T;
while (T--) {
cin >> n;
double d1 = n * 1.0 * 2.0 + 1.0;
double d2 = 4.0 * n;
double d3 = d1 / d2;
double temp = cos(PI * d3);
double ans = 1.0 / (2.0 * temp);
ans *= -1.0;
printf("%.9f\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
unsigned long long n, m, k;
vector<long long> a(1e5 + 1);
int main() {
unsigned int t;
cin >> t;
while (t--) {
cin >> n;
double f_2 = 0.5 * 3.14159265358979323846 / (double)n;
double a;
if (n % 2) {
double f_3 = 1.57079632679489661923 -
ceil(0.5 * (0.78539816339744830962 - f_2) / f_2) * 2.0 * f_2;
a = 0.5 / sin(f_2);
double d_2 = a * (sin(f_3) + cos(f_3));
a = d_2 / sin(0.78539816339744830962);
} else
a = 1.0 / tan(f_2);
printf("%.8lf\n", a);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const long long INF = 1e18;
const double pi_2 = 1.57079632679489661923;
long long biex(long long a, long long b) {
if (b == 0) return 1;
long long ans = biex(a, b / 2);
ans = (ans * ans) % M;
if (b & 1)
return (ans * a) % M;
else
return ans;
}
void solve() {
int n;
cin >> n;
double a = pi_2 / n;
double d = sin(a);
double nu = sin(pi_2 / 2 + a * 2);
for (int i = 2; i <= (n - 1) / 2; i++) {
nu = max(nu, sin(pi_2 / 2 + a * 2 * i));
}
cout << fixed << setprecision(9) << (double)nu / (double)d << "\n";
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) solve();
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.