Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, m;
vector<long long> bs;
int cnt[(1 << 16) + 1];
long long inv2 = (998244353 + 1) / 2;
int popcount(long long x) { return __builtin_popcountll(x); }
bool add(long long x) {
for (auto& t : bs) x = min(x, t ^ x);
if (!x) return false;
f... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
int v = 0, f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-')
f = -1;
else
v = (c & 15);
while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
x = v * f;
}
inline void read(lo... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int maxN = 200005, maxM = 60, p = 998244353;
void MOD(int &x) {
if (x >= p) x -= p;
}
int N, M, K;
long long A[maxM], B[maxM];
int pow2[maxN], ipow2[maxM];
void Insert(long long x) {
for (int i = M - 1; ~i; i--)
if ((x >> i) & 1) {
if (A[i])
x ^=... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 100;
const long long inf = 0x3f3f3f3f;
const long long iinf = 1 << 30;
const long long linf = 2e18;
const long long mod = 998244353;
const double eps = 1e-7;
template <class T = long long>
T chmin(T &a, T b) {
return a = min(a, b);
}
template ... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
const int mod =... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, m;
vector<long long> bs;
int cnt[(1 << 16) + 1];
long long inv2 = (998244353 + 1) / 2;
int popcount(long long x) {
return cnt[x & 65535] + cnt[x >> 16 & 65535] + cnt[x >> 32 & 65535] +
cnt[x >> 48 & 65535];
}
bool add(long long x... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chkmin(T &x, T y) {
return x > y ? x = y, 1 : 0;
}
template <typename T>
bool chkmax(T &x, T y) {
return x < y ? x = y, 1 : 0;
}
long long readint() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
const int MAXN = 53 + 5;
const int ha = 998244353;
const int inv2 = 499122177;
int n, m;
long long b[MAXN];
inline void insert(long long x) {
for (int i = m - 1; i >= 0; --i) {
if ((x >> i) & 1) {
if (b[i])
x ^= b[i];
else {
b[i] = x;
break;
}
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int maxN = 223456;
const int P = 998244353;
int n, m, rnk;
i64 base[maxN], p[maxN], dp[60][60][2];
int cnt[maxN], ans[maxN];
void dfs1(int d, i64 x) {
if (d == rnk) {
cnt[__builtin_popcountll(x)]++;
} else {
dfs1(d + 1, x);
dfs1(... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, m;
vector<long long> bs;
int cnt[(1 << 16) + 1];
long long inv2 = (998244353 + 1) / 2;
int popcount(long long x) { return __builtin_popcountll(x); }
bool add(long long x) {
for (auto& t : bs) x = min(x, t ^ x);
if (!x) return false;
f... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
for (const auto &x : v) os << sep << x, sep = ", ";
return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
re... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int M = 55;
const int mod = 998244353;
const int inv2 = (mod + 1) / 2;
inline int pls(int a, int b) {
a += b - mod;
return a + (a >> 31 & mod);
}
inline int mns(int a, int b) {
a -= b;
return a + (a >> 31 & mod);
}
inline void inc(int& a, int b) {
a += b - m... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
;
for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
return x;
}
const int Mod = 998244353, inv2 = Mod + 1 >> 1, MAXW = (1 << 18) - 1;
int upd(i... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
namespace mine {
long long qread() {
long long ans = 0, f = 1;
char c = getchar();
while (c < '0' or c > '9') {
if (c == '-') f = -1;
c = getchar();
}
while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar();
return ans * f;
}
void write(lon... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long long MOD1 = 2286661337;
const long long MOD2 = 998244353;
const int INF = (int)1e9 + 7;
const double EPS = 1e-7;
const int N = (int)2e5;
const int M = 53;
int n, m, k;
long long a[N], b[M], in_basis[M], p[M + 1], q[M + 1]... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m;
long long P[55], B[55], T[55], Comb[55][55];
void Put(long long a) {
int i;
for (i = m; i >= 0; i--) {
if ((a >> i) & 1) {
if (!P[i]) {
P[i] = a;
return;
}
a ^= P[i];
}
}
}
int C[55], Mod = 998244353;
void DFS(int pv... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, m, num = 0, cnt[300010];
long long a, b[110], c[110], sum[110], pw2[200010], C[110][110];
int getcnt(long long x) {
return cnt[x & ((1 << 18) - 1)] + cnt[(x >> 18) & ((1 << 18) - 1)] +
cnt[x >> 36];
}
long long power(long long a,... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
for (const auto &x : v) os << sep << x, sep = ", ";
return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
re... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int P = 998244353;
int pw2(int y) {
if (y < 0) y += P - 1;
int x = 2;
int s = 1;
for (; y; y >>= 1, x = (long long)x * x % P)
if (y & 1) s = (long long)s * x % P;
return s;
}
int k, c[100];
long long a[100];
void calc(int t, long long x) {
if (t > k) {... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <int MOD_>
struct modnum {
static constexpr int MOD = MOD_;
static_assert(MOD_ > 0, "MOD must be positive");
private:
using ll = long long;
int v;
static int minv(int a, int m) {
a %= m;
assert(a);
return a == 1 ? 1 : int(m - ll(minv(m, a)) ... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
return !b ? a : gcd(b, a % b);
}... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T &t1, T t2) {
t1 = max(t1, t2);
}
template <typename T>
void mintt(... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar()) {
if (ch == '-') f = -1;
}
for (; isdigit(ch); ch = getchar()) {
x = x * 10 + ch - 48;
}
return x * f;
}
const int mxN = 1 << 19;
const int mxM = 53;
const ... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
template <int MOD>
struct Integral {
int v_ = 0;
template <typename T>
Integral(T v) : v_(norm(v)) {
static_assert(std::is_integral<T>::value, "input should be an integral.");
}
Integral() = default;
~Integral() = default;
template <typename T>
T norm(T v) const {
if con... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a[200010], b[100], v[100], p[100], r[100], t[100], pw[200010],
c[100][100], g[100][100], n, rk, m, ct;
void ins(long long x) {
for (long long i = m; ~i; i--)
if (x & (1ll << i)) {
if (b[i])
x ^= b[i];
else {
b[i] = x;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long inf;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T, class T2>
long long chkmin(T &a, T2 b) {
return a > b ? a = b, 1 : 0;
}
template <class T, class T2>
long long chkmax(T &a, T2 b) {
return a < b ? a = b, 1 : 0;
}
template <class T>... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int N = 2e5 + 5;
const int M = 110;
const int inv2 = (mod + 1) >> 1;
int n, m;
int bin[M][M];
struct LinarBase {
long long b[M];
int rk;
bool side[M];
void insert(long long s) {
for (int i = m - 1; ~i; i--)
if (1 & (s >> i)... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
;
for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
return x;
}
const int Mod = 998244353, inv2 = Mod + 1 >> 1, MAXW = (1 << 18) - 1;
int upd(i... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 60;
const int mod = 998244353;
long long gi() {
long long x = 0, o = 1;
char ch = getchar();
while (!isdigit(ch) && ch != '-') ch = getchar();
if (ch == '-') o = -1, ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return ... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
struct MI {
private:
char bb[1 << 14];
FILE* f;
char *bs, *be;
char e;
bool o, l;
public:
MI() : f(stdin), bs(0), be(0) {}
inline char get() {
if (o) {
o = 0;
return e;
}
if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(bb), f);
if (bs == be) {
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int M = 55, P = 998244353;
int n, m, c[M][M], g[M][M];
long long b[M];
vector<long long> B, G;
int f[60], p[60];
long long pw(long long a, long long m) {
long long res = 1;
while (m) m & 1 ? res = res * a % P : 0, a = a * a % P, m >>= 1;
return res;
}
void inser... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int const p = 998244353;
int mod(int x) { return x >= p ? x - p : x; }
int pw(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res = 1ll * res * x % p;
x = 1ll * x * x % p;
y >>= 1;
}
return res;
}
int n, m, k, ans[55], d[55][55], C[55][55];
long long... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, m, rk, r, c;
int C[65][65], h[65];
long long p[65], t[65], s[65];
inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
inline void insert(long l... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline void cmin(T &a, const T &b) {
((a > b) && (a = b));
}
template <class T>
inline void cmax(T &a, const T &b) {
((a < b) && (a = b));
}
char IO;
template <class T = int>
T rd() {
T s = 0;
int f = 0;
while (!isdigit(IO = getchar()))
if (... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
namespace IO {
char gc() { return getchar(); }
template <typename Tp>
bool get1(Tp &x) {
bool neg = 0;
char c = gc();
while (c != EOF && (c < '0' || c > '9') && c != '-') c = gc();
if (c == '-') c = gc(), neg = 1;
if (c == EOF) return false;
x = 0;
for (; c >= '0' && c <= '9'; c =... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
namespace IO {
char gc() { return getchar(); }
template <typename Tp>
bool get1(Tp &x) {
bool neg = 0;
char c = gc();
while (c != EOF && (c < '0' || c > '9') && c != '-') c = gc();
if (c == '-') c = gc(), neg = 1;
if (c == EOF) return false;
x = 0;
for (; c >= '0' && c <= '9'; c =... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long N = 57;
const long long M = 262144;
const long long INF = 1e9 + 7;
const long long mod = 998244353;
long long Pow(long long x, long long y) {
long long ans = 1, now = x;
while (y) {
if (y & 1) ans = ans * now % mod;
now = now * now % mod;
y >... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1, M = 64, mod = 998244353;
inline void check(int& x) { x -= mod, x += x >> 31 & mod; }
int n, k, m, tot;
long long int a[N], f[M], g[M], t[M];
int ans[M], tmp[M], pw[N], c[M][M], w[M][M];
inline void ins(long long int x) {
for (int i = m; i >= 0; i--)... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
struct Z2Basis {
long long int a[53];
int sz;
void add(long long int x) {
for (int i = 0; i < 53; i++)
if ((x >> i) & 1) {
if ((a[i] >> i) & 1)
x ^= a[i];
else {
a[i] = x;
sz++;
return;
}
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long qpow(long long x, long long y) {
while (y < 0) y += 998244353 - 1;
long long res = 1;
while (y) {
if (y & 1) res = res * x % 998244353;
x = x * x % 998244353;
y = y / 2;
}
return res;
}
int n, m;
long long vis[200], ypa;
void ins(long long x)... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long qpow(long long a, long long b) {
long long r = 1;
while (b) {
if (b & 1) r = r * a % 998244353;
a = a * a % 998244353, b >>= 1;
}
return r;
}
long long read() {
long long x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long pow_mod(long long x, int k) {
long long ans = 1;
while (k) {
if (k & 1) ans = ans * x % 998244353;
x = x * x % 998244353;
k >>= 1;
}
return ans;
}
long long C[60][60];
void pre(int n) {
for (int i = 0; i <= n; i++) C[i][0] = 1;
for (int i =... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
long long n, m, a[1100005], cntA, A[1100005], C[105][105], G[105][105],
ans[105], S[1100005], E[1100005], cnt[1100005];
long long read() {
char c = getchar();
long long ans = 0;
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getc... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int M = 55, P = 998244353;
int n, m, c[M][M], g[M][M];
long long b[M];
vector<long long> B, G;
int f[60], p[60];
long long pw(long long a, long long m) {
long long res = 1;
while (m) m & 1 ? res = res * a % P : 0, a = a * a % P, m >>= 1;
return res;
}
void inser... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxm = 54;
int n, m, k;
long long first[maxm], a[maxm], b[maxm], p[maxm];
long long c[maxm][maxm];
int ipow(long long b, int e) {
long long ret = 1;
for (; e; e >>= 1) {
if (e & 1) ret = ret * b % mod;
b = b * b % mod;
}
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
;
for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
return x;
}
const int Mod = 998244353, inv2 = Mod + 1 >> 1, MAXW = (1 << 18) - 1;
int upd(i... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int MAXM = 60;
int N, M;
int B;
vector<long long> basis;
int nc[MAXM];
long long ans[MAXM];
void gogo() {
long long cv = 0;
for (int i = 1; i < (1 << B); i++) {
nc[__builtin_popcountll(cv)]++;
cv ^= basis[__builtin_ctz(i)];... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 20 | 1;
inline char gc() {
static char ibuf[RLEN], *ib, *ob;
(ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
return (ib == ob) ? EOF : *ib++;
}
inline int read() {
char ch = gc();
int res = 0;
bool f = 1;
while (!isdigit(c... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int n, m, num = 1, rnk, k, ans[100], res[100], C[100][100];
long long b[100], a[100], c[100];
void insert(long long x) {
for (int i = m - 1; ~i; i--)
if (x >> i & 1) {
if (b[i])
x ^= b[i];
else {
for (int j = i - ... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long read() {
long long x = 0;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
;
for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
return x;
}
const int Mod = 998244353, inv2 = Mod + 1 >> 1, MAXW = (1 << 18) - 1;
int upd(i... | CPP |
1336_E2. Chiori and Doll Picking (hard version) | This is the hard version of the problem. The only difference between easy and hard versions is the constraint of m. You can make hacks only if both versions are solved.
Chiori loves dolls and now she is going to decorate her bedroom!
<image>
As a doll collector, Chiori has got n dolls. The i-th doll has a non-negati... | 2 | 11 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target( \
"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
os << '{';
string sep;
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | # abs((desired*(2*n + 1) - ((n+1)*hot + n*cold))/(2*n + 1))
#EXPERIMENTING WITH LOSS DEFINTION - float ops ko aage peeche kar diya
import sys
def input():
return sys.stdin.readline().rstrip()
testcases = int(input())
answers = []
def loss(two_n_plus_one, hot, cold, desired):
n = two_n_plus_one//2
# if n == 0:
#... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | # Nilfer
for _ in range(int(input())):
p,a,t=map(int,input().split())
if t<=(p+a)/2:print(2)
else:
k=(p-t)//(2*t-p-a)
if abs((2*k+3)*t-k*p-2*p-k*a-a)*(2*k+1)<abs((2*k+1)*t-k*p-p-k*a)*(2*k+3):print(2*k+3)
else:print(2*k+1) | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | eps = 1e-10
t = int(input())
for _ in range(t):
h, c, t = map(int, input().split())
l = 0
r = 100000000
while l + 1 < r:
mid = (l + r) // 2
if mid % 2 == 0:
if mid + 1 < r:
mid += 1
elif mid - 1 > l:
mid -= 1
else:
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | tt=int(input())
while(tt):
h,c,t=map(int,input().split())
if h == t:
print(1)
elif t <= (h + c) / 2:
print(2)
else:
k = (t - c - 1) // (2 * t - h - c)
ans = 2 * k + 1
if(((4 * k * k - 1) * (2 * t - h - c)) >= (2 * (h - c) * k)):
ans -= 2
prin... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import math
T = int(input())
for test in range(T):
h, c, t = map(int, input().split())
if h + c - 2 * t >= 0:
print(2)
elif h <= t:
print(1)
else:
x = int((h - t) / (2 * t - h - c))
xp1 = x + 1
if abs((h + c) * x + h - 2 * x * t - t) * (2 * xp1 + 1) <= abs((h + ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for _ in range(int(input())):
h,c,t=[float(i) for i in raw_input().split()]
if t<=(h+c)/2:
print(2)
else:
val=(t-c)/(2*t-h-c)
x1=int(val)
diff=h*x1+c*(x1-1)
diff=abs(t*(2*x1-1)-diff)
x1+=1
diff2=h*x1+c*(x1-1)
diff2=abs(t*(2*x1-1)-diff2)
... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')
from decim... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for _ in range(int(input())):
h, c, t = map(int, input().split())
if 2 * t <= h + c:
print(2)
continue
x = (h - t) // (2*t - h - c)
k = 2*x + 1
val1 = abs(k//2 * c + (k+1)//2 * h - t*k)
val2 = abs((k+2)//2 * c + (k+3)//2 * h - t*(k+2))
print(k if val1 * (k... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | //package learning;
import java.util.*;
import java.io.*;
import java.lang.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class NitsLocal {
static ArrayList<String> s1;
static boolean[] prime;
static int n = 200001;
static void sieve() {
Arrays.fill(prime , true);
prim... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
input = sys.stdin.buffer.readline
def print(val):
sys.stdout.write(str(val) + '\n')
def temp(x,t,h,c):
return abs((t*(2*x+1) - ((x+1)*h + x*c))/(2*x+1))
def prog():
for _ in range(int(input())):
h,c,t = map(int,input().split())
if t <= (h+c)/2:
print(2)
else:
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #8:47
MOD=10**9+7
INT_MAX=10**20+7
def INPUT():return list(float(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
def power(a,x):
res=1
while(x>0):
if x&1:
res=(res*a)%MOD
a=(a*a)%MOD... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
c b, e;
};
template <class c>
rge<c> range(c i, c j) {
return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
template <class c>
debug& operator<<(const c&... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.nio.charset.Charset;
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int i = 0; i < t; i++) {
double h = sc.nextInt();
double c = sc.nextInt();
do... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int te;
cin >> te;
for (int q = 0; q < te; q++) {
long long h, c, t;
cin >> h >> c >> t;
if (c + h - 2 * t >= 0) {
cout << 2 << '\n';
continue;
}
long long x = (h - t) / (2 * t - h - c);
long double tb1 = double((x + 2)... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from fractions import Fraction
for _ in range(int(input())):
h,c,t=map(Fraction,input().split())
if 2*t<=(h+c):
print(2)
else:
x1=(h-t)//(2*t-h-c)
x2=x1+1
x1,x2=Fraction(x1),Fraction(x2)
y1,y2=Fraction(h*(x1+1)+c*x1)/Fraction(2*x1+1),Fraction(h*(x2+1)+c*x2)/Fraction(2... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | def main(h, c, t):
lowtmp = (h + c) / 2
if t == h: return 1
if t <= lowtmp: return 2
def tempSum(n):
# note, here we cannot get temp but only to get tempSum
# otherwise the tmp we get will have not enough floating precision
return (n * h + (n - 1) * c) # / (2* n -1)
l = 1
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from __future__ import division
from sys import stdin
from decimal import Decimal
ceil1 = lambda a, b: (a + b - 1) // b
out = []
for _ in range(int(input())):
h, c, t = map(int, stdin.readline().split())
d1, d2 = h - t, t - c
if d1 >= d2:
out.append(2)
else:
lo = (c - t) // (h + c - 2 ... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | def f(h: int, c: int, t: int) -> int:
if h + c >= t * 2:
return 2
else:
x = (h - t) // (t * 2 - h - c)
lhs = (h * (x + 1) + x * c) * (x * 2 + 3) - \
t * (x * 2 + 1) * (x * 2 + 3)
rhs = t * (x * 2 + 1) * (x * 2 + 3) - \
(h * (x + 2) + (x + 1) * c) * (x * 2 ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from math import ceil ,floor
for _ in range(int(input())):
h,c,t=map(int,input().split())
if t==h:
print(1)
elif t<=(h+c)/2:
print(2)
else:
f=(h-t)/(2*t-h-c)
# print(f,abs((c*ceil(f)+(ceil(f)+1)*h)/(2*ceil(f)+1) -t ),abs((c*floor(f)+(floor(f)+1)*h)/(2*floor(f)+1)-t))
val1=((c*ceil(f)+(ceil(f)+1)*h)-t*(2*... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | // Don't place your source in a package
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
// Please name your class Main
public class Main {
public static void main (String[] args) throws java.lang.Exception {
Scanner in = new Scanner(System.in);
int T =in.nextInt();
for(int i=0;i... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
input = sys.stdin.readline
def print(val):
sys.stdout.write(str(val) + '\n')
def val(x,h,c):
return (h-c)/(2*(x*2 -1))
def prog():
for _ in range(int(input())):
L = 1
R = 10**12
h,c,t = map(int,input().split())
if t <= (h+c)/2:
print(2)
else:
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import math
for _ in range(int(input())):
h, c, t = map(int, input().split())
if 2 * t <= h + c:
print(2)
continue
if t >= h:
print(1)
continue
n = int((h - t) / (2 * t - h - c))
t1 = abs(((h + c) * n + h) - t * (2 * n + 1)) * (2 * n + 3)
t2 = abs(((h + c) * (n + ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.*;
import java.math.*;
import java.util.*;
public class Main{
static long MOD = 1000000007L;
static long [] fac;
static int[][] dir = new int[][]{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
static long lMax = 0x3f3f3f3f3f3f3f3fL;
static int iMax = 0x3f3f3f3f;
static HashMap <Long, Long> ... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.StringTokenizer;
/*
1
50 10 49
2
99999 0 50000
99999 0 50002
*/
public class C2 {
static double EPS=1e-8;
public static void main(String[] args) {
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long h, c, t;
cin >> h >> c >> t;
if ((h + c) / 2 >= t) {
cout << 2 << '\n';
return;
}
long long a = t - h;
long long b = h + c - 2 * t;
long long k = 2 * (a / b) + 1;
long long val2 =
abs((k + 2) / 2 * 1ll * c + (k + 3) / 2... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | // Java implementation of the approach
import java.io.*;
import java.util.*;
public class Solution {
public static class FastReader {
BufferedReader br;
StringTokenizer root;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (root == n... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | a=int(input())
from fractions import Fraction
import sys
input=sys.stdin.readline
for i in range(a):
h,c,t=map(int,input().split())
se=(h+c)/2
if(h==c):
print(1)
elif(t<=se):
print(2)
elif(t>se):
x=h-t
y=2*(t-se)
if(x%y==0):
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
import math
import collections
from sys import stdin,stdout,setrecursionlimit
import bisect as bs
setrecursionlimit(2**20)
M = 10**9+7
T = int(stdin.readline())
# T = 1
def ceil(x,y):
return x//y + (1 if x%y != 0 else 0)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys,math
from collections import deque
#input = sys.stdin.buffer.readline
def solve():
return;
for _ in range(int(input())):
h,c,t = map(int,input().split())
if t<=(h+c)/2:
print(2)
else:
x = (h-t)//(2*t-h-c)
v1 = ((x+1)*h + x*c)
v2 = ((x+2)*h + (x+1)*c)
# print(v1,v2)
# print(abs(v1-(2*x+1)*... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for _ in range(int(input())):
h,c,t = map(int,input().split())
if(h==t):print(1)
else:
xx=(h+c)/2
if(xx>=t): print(2)
else:
dif=(t-xx)
j=int(abs((c-h)//(2*dif)))
if(j%2==0):
j+=1
if(dif-(h-c)/(2*j)>=abs(dif-(h-c)/(2... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from fractions import *
T = input()
def calc(h, total, Tmult):
mult = Tmult*2+1
return Fraction(h)/Fraction(mult) + Fraction(Tmult)*Fraction(total)/Fraction(mult)
for _ in xrange(T):
h, c, t = map(float, raw_input().split())
total = h+c
if t == h:
print 1
elif total%2 == 0 and t == ... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.Scanner;
public class C1359 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int T = in.nextInt();
StringBuilder output = new StringBuilder();
for (int t=0; t<T; t++) {
int H = in.nextInt();
int C = in.nextInt(... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sun.nio.cs.ext.MacThai;
import java.io.*;
import java.util.*;
public class Codeforces {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
InputStreamReader(System.in));
}
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int cas;
cin >> cas;
while (cas--) {
int h, t, c;
cin >> h >> c >> t;
h -= c;
t -= c;
if (h >= 2 * t) {
cout << 2 << endl;
} else {
LL n... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from fractions import Fraction as f
def answer():
h, c, t = list(map(int, input().split()))
if t <= (h+c)/2:
return 2
else:
if abs(t - h) <= abs(t - (h*2 + c)/3):
return 1
n = int((t - h) / (h + c - 2*t))
i = max(2,n-2)
while abs(t -f( h*i + c*(i... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | t=int(input())
for _ in range(t):
h,c,t=map(int,input().split(" "))
tb = (h+c)//2
if t==h:
print(1)
else:
if t<=tb:
print(2)
else:
k=(t-h)//(h+c-2*t)
if abs((k*(h+c)+h)-t*(2*k+1))*(2*k+3)<=abs(((k+1)*(h+c)+h)-t*(2*k+3))*(2*k+1):
... | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.