solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int t, a, b; vector<pair<int, int>> pa, pb; vector<int> pr; bool vis[N]; bool val() { if (a * a != b && b * b != a) return false; if (pa.size() != pb.size()) return false; for (int i = 0; i < pa.size(); i++) { if (pa[i].first != pb[i].first)...
7
CPP
#include <bits/stdc++.h> using namespace std; int x, y; int prime[100005]; bool is_prime[100005]; int t; int sieve(int n) { int p = 0; for (int i = 0; i <= n; i++) is_prime[i] = true; is_prime[0] = is_prime[1] = false; for (int i = 2; i <= n; i++) { if (is_prime[i]) { prime[p++] = i; for (int j ...
7
CPP
#include <bits/stdc++.h> using namespace std; int T; long long a, b, x; int main() { for (cin >> T; T--;) { scanf("%lld%lld", &a, &b), x = pow(a * b, 1. / 3); if ((x + 1) * (x + 1) * (x + 1) == a * b) x++; puts(x * x * x != a * b || a % x || b % x ? "No" : "Yes"); } }
7
CPP
#include <bits/stdc++.h> using namespace std; const long long N = 1e5 + 5; long long dx[] = {1, -1, 0, 0}; long long dy[] = {0, 0, 1, -1}; void solve() { long long a, b; cin >> a >> b; long long num = a * b; long long x = round(cbrt(num)); if (x * x * x != num) cout << "No"; else { if (a % x == 0 &&...
7
CPP
#include <bits/stdc++.h> using namespace std; template <typename T> using vc = vector<T>; template <typename T, typename X> using pr = pair<T, X>; const long long int MOD = 1e9 + 7; const long double PI = 3.14159265; long long int powerWithMod(long long int base, long long int exponent, long ...
7
CPP
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction mod = 10 ** 9 + 7 mod1 = 998244353 # ------------------------------warmup---------------------------- impor...
7
PYTHON3
import sys input = sys.stdin.buffer.readline def gcd(a, b): if a > b: a, b = b, a if b % a==0: return a return gcd(b % a, a) def process(a, b): g = gcd(a, b) r = a//g s = b//g if g % r != 0: return 'No' g = g//r if g % s != 0: return 'No' G3 = ...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const char letters[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; const int dx[] = {0, -1, 0, 1, -1, -1, 1, 1}; const int dy[] = {1, 0, -...
7
CPP
#include <bits/stdc++.h> namespace chtholly { inline int read() { int x = 0, f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) f ^= c == '-'; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ '0'); return f ? x : -x; } template <typename mitsuha> inline bool read(mitsuha &x) { x =...
7
CPP
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 9; long long gcd(long long a, long long b) { long long c; while (b) { c = a % b; a = b; b = c; } return a; } int main() { int t; ios::sync_with_stdio(0); cin >> t; while (t--) { long long a, b; cin >> a >> b; lo...
7
CPP
#include <bits/stdc++.h> using namespace std; const long double pi = 3.1415926535897932384626433832795l; template <typename T> inline auto sqr(T x) -> decltype(x * x) { return x * x; } template <typename T1, typename T2> inline bool umx(T1& a, T2 b) { if (a < b) { a = b; return 1; } return 0; } template...
7
CPP
#include <bits/stdc++.h> using namespace std; bool solve() { int a, b; scanf("%d %d", &a, &b); int both = int(floor(pow((double)a * b, 1.0 / 3) + 0.5)); if (both == 0) return a == 1 && b == 1; if (a % both != 0 || b % both != 0) return false; if ((long long)a * b != (long long)both * both * both) return fal...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf("%d", &T); while (T--) { int a, b; scanf("%d%d", &a, &b); int64_t x = a * (int64_t)b, y = cbrtl(x) + 0.5; puts(y * y * y == x && a % y == 0 && b % y == 0 ? "Yes" : "No"); } }
7
CPP
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a < b) swap(a, b); if (b == 0) return a; return gcd(b, a % b); } int main() { unordered_set<int> cube; for (int i = 1; i <= 1000; i++) cube.insert(i * i * i); int N; scanf("%d", &N); for (int i = 0; i < N; i++) { int a, b, c, ...
7
CPP
#include <bits/stdc++.h> using namespace std; using lint = long long; void solve(istream& cin, ostream& cout) { int n; cin >> n; for (int in = (0); in < int(n); ++in) { lint a, b; cin >> a >> b; lint c = a * b; lint x = lint(pow(c, 1.0 / 3)) - 3; x = max<lint>(1, x); bool ok = false; w...
7
CPP
#include <bits/stdc++.h> using namespace std; vector<long long int> cube; int main() { int t, u, v; long long int x; for (long long int i = 1; i <= 1000000; i++) cube.push_back(i * i * i); scanf("%d", &t); while (t--) { scanf("%d %d", &u, &v); x = (long long int)u * v; int p = lower_bound(cube.beg...
7
CPP
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 9; const int mod = 1e9 + 7; int n, m, k; const int MX = 1000010; int sito[MX + 5]; vector<int> primes; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long int a, b; cin >>...
7
CPP
import os import sys from io import BytesIO, IOBase # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.wr...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; void boost() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long cubic_root(long long x) { long long l = 0, r = 2000005; while (l != r) { long long m = (l + r + 1) / 2; if (m * m * m > x) r = m - 1; else l = m; ...
7
CPP
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> ...
7
CPP
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { if (a.second == b.second) return a.first < b.first; return a.second < b.second; } int main() { ios::sync_with_stdio(false); cin.tie(0); long long m, a, ans, c, g, d; cin >> m; while (m--) {...
7
CPP
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction mod = 10 ** 9 + 7 mod1 = 998244353 # ------------------------------warmup---------------------------- impor...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 16; int lpf[N]; void init() { memset(lpf, -1, sizeof(lpf)); for (int n = 2; n < N; n++) { if (lpf[n] == -1) { lpf[n] = n; if (n < N / n) { for (int m = n * n; m < N; m += n) { if (lpf[m] == -1) lpf[m] = n; } ...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long a, i, x, y; scanf("%I64d ", &a); while (a--) { scanf("%I64d %I64d", &x, &y); i = ceil(cbrt(x * y)); if (x % i == 0 && y % i == 0 && (x * y) % i == 0) { printf("Yes\n"); } else printf("No\n"); } }
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t-- > 0) { long long a, b; cin >> a >> b; string res = "No\n"; long long raiz = cbrt(a * b); for (long long i = max(1LL, raiz - 2); i < raiz + 2; ++i) ...
7
CPP
#include <bits/stdc++.h> using namespace std; long long pow3(long long a, long long b, long long m = 1000000007) { long long res = 1; while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res; } void solve() { long long a, b; scanf("%lld %lld", &a, &b); long long s...
7
CPP
#include <bits/stdc++.h> using namespace std; template <typename T> map<T, long long int> factorize(T x) { map<T, long long int> res; for (long long int i = 2; i * i <= x; i++) { while (x % i == 0) { x /= i; res[i]++; } } if (x != 1) res[x]++; return res; } int main() { cin.tie(0); ios...
7
CPP
#include <bits/stdc++.h> using namespace std; long long int power(long long int a, long long int b, long long int m) { long long int ans = 1; while (b) { if (b & 1) { ans = ((ans % m) * (a % m)) % m; } a = ((a % m) * (a % m)) % m; b = b >> 1; } return ans; } long long int powe(long long in...
7
CPP
#include <bits/stdc++.h> using namespace std; void solve() { long long int a, b; cin >> a >> b; long long int prod = a * b; long long int l = 1; long long int r = 1e6; long long int mid; while (l <= r) { mid = (l + r) / 2; if (mid * mid * mid == prod) { break; } if (mid * mid * mid <...
7
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); ll n; cin >> n; ll a, b, x, y, m; while (n--) { cin >> a >> b; x = 0, y = 1000000; while (x <= y) { m = x + (y - x) / 2; if (m * m * m == a * b) { x = m; break;...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; int cnt = 1; while (T--) { long long A, B, C; scanf("%lld %lld", &A, &B); C = A * B; long long sm = (long long)(pow(C, 1 / 3.0) + 0.5); if (sm * sm * sm != C || sm > min(A, B) || A % sm || B % sm) printf("No\n"...
7
CPP
#include <bits/stdc++.h> using namespace std; int n, i, j, k, x, y, w, path_w, m, a[100500]; int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); } int main() { cin >> n; for (i = 0; i < n; i++) { scanf("%d %d", &x, &y); int g = gcd(x, y); int dlfjl = x / g, y1 = y / g; if (y % (1LL * y1 * y...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf("%d", &T); while (T--) { long long x, y, le = 1, ri = 1e6, mi, o; scanf("%lld%lld", &x, &y); while (le + 1 < ri) { mi = (le + ri) >> 1; if (mi * mi * mi > x * y) ri = mi; else le = mi; } i...
7
CPP
#include <bits/stdc++.h> using namespace std; int bin(long long a, long long b) { long long t = a * b; long long l = 1, h = 1E6, m; while (l <= h) { m = (l + h) / 2; if (m * m * m == t) return m; if (m * m * m > t) { h = m - 1; } else { l = m + 1; } } return 0; } int main() { ...
7
CPP
#include <bits/stdc++.h> using namespace std; void fileio() {} vector<vector<long long int>> g; long long int cube_root(long long int x) { long long int lo = 0, hi = 1e6 + 10; while (lo <= hi) { long long int m = (lo + hi) / 2; long long int val = m * m * m; if (val == x) return m; if (val > x) { ...
7
CPP
#include <bits/stdc++.h> using namespace std; long long a, b, c, x; int n; long long s3(long long x) { long long l = 1, r = 1e6, res = -1; while (l <= r) { long long mid = (l + r) >> 1, val = mid * mid * mid; if (val == x) return mid; if (val < x) l = mid + 1; if (val > x) r = mid - 1; } return ...
7
CPP
import io import os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline t = int(input()) for tc in range(t): a, b = map(int, input().split()) cbrt = round(pow(a*b, 1/3)) if pow(cbrt, 3) == a*b: if a % cbrt == b % cbrt == 0: print("Yes") continue print("No")
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long rt3(long long x) { long long l = 0, r = 1e6; for (int i = 0; i < 30; i++) { long long h = (l + r) / 2; if (h * h * h < x) { l = h; } else { r = h; } } return r; } long long min(long long a, long long b) { return a < b ? a : b; }...
7
CPP
#include <bits/stdc++.h> using namespace std; long long GCD(long long x, long long y) { while (y != 0) { long long t = x % y; x = y; y = t; } return x; } long long n, a, b; long long cs; bool calc() { scanf("%lld %lld", &a, &b); long long g = GCD(a, b); long long p = a / g; long long q = b / g...
7
CPP
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e9 + 9; const long long N = 500500; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); vector<long long> cube; for (long long i = 1; i <= 1e6; i++) { cube.push_back(i * i * i); } long long T; ...
7
CPP
#include <bits/stdc++.h> using namespace std; const int MAXR = 1000005; long long cubic_root(long long x) { long long l = 0, r = MAXR; while (l != r) { long long m = (l + r + 1) / 2; if (m * m * m > x) r = m - 1; else l = m; } return l; } int main() { int n; scanf("%d", &n); for (i...
7
CPP
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 5; int t; long long a, b; long long cubic_root(long long x) { long long lo = 1, hi = 1e6, mid; while (lo < hi) { mid = (lo + hi) / 2; if (mid * mid * mid < x) lo = mid + 1; else hi = mid; } return lo; } int main() { scan...
7
CPP
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007LL; long long base = 37; long long large = 1000000000000000000LL; bool iscube(int x) { int low = 1; int high = 1000; int mid; int ans = 1; while (low <= high) { mid = (low + high) / 2; if (mid * mid * mid <= x) { ans = mid; ...
7
CPP
#include <bits/stdc++.h> using namespace std; bool vis[100010]; int pr[100010], e; void Shai() { vis[1] = true; for (long long i = 2; i <= 1000ll; i++) { if (!vis[i]) { pr[++e] = i; for (long long j = i * i; j <= 1000ll; j += i) { vis[j] = true; } } } } int n, cnta[100010]; int m...
7
CPP
#include <bits/stdc++.h> using namespace std; int n; long long x, y, m; double ret; int main() { scanf("%d", &n); while (n--) { scanf("%lld %lld", &x, &y); ret = pow((double)(x * y), 1.0 / 3.0); m = round(ret); if (m * m * m != (x * y) || x % m || y % m) puts("No"); else puts("Yes");...
7
CPP
import os, sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable ...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; int a, b, k, u, v; map<int, bool> OK; int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); } void solve() { scanf("%d%d", &a, &b); k = GCD(a, b); u = a / k; v = b / k; if (k % u != 0) { puts("No"); return; } else k /= u; if (k % v != 0) { ...
7
CPP
#include <bits/stdc++.h> int main() { std::ios::sync_with_stdio(0); std::cin.tie(0); int number; std::cin >> number; while (number--) { int a, b; std::cin >> a >> b; int const c = (int)std::round(std::cbrt(a * (int64_t)b)); std::cout << ((int64_t)c * c * c == (int64_t)a * b and a % c == 0 and ...
7
CPP
#include <bits/stdc++.h> using namespace std; long long ff(long long a) { long long le = 1, ri = 1000010; while (le <= ri) { long long mi = (le + ri) / 2; if (mi * mi * mi > a) ri = mi - 1; else le = mi + 1; } return ri; } int main() { int _; scanf("%d", &_); while (_--) { int ...
7
CPP
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = (1000000007LL)) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } long long gcd(long long a, long long b) { if (b == 0) r...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; long long a, b; cin >> n; while (n--) { cin >> a >> b; long long c = a * b; bool ok = false; long long left = 1, right = 1000001; long long ans; while (left <= right) { ...
7
CPP
#include <bits/stdc++.h> using namespace std; const long long INF = int(1e6) + 5; long long cubic_root(long long x) { long long l = 0, r = INF, med, answ; while (l <= r) { med = l + (r - l) / 2; if (med * med * med >= x) { answ = med; r = med - 1; } else { l = med + 1; } } retu...
7
CPP
#include <bits/stdc++.h> using namespace std; long long a, b, c[1234567], d[1234567], c1[1234][1234], e[1234567], n, j, i, l, r, x, y, k, ans; bool used[1234567]; long long T; char ch[1234][1234]; long long vis[1234][1234]; vector<long long> v[1234567], v1; string s1[1234567]; int main() { cin >> T; while (T--)...
7
CPP
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 0; char ch = getchar(); while (ch < '0' || '9' < ch) f |= ch == '-', ch = getchar(); while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return f ? -x : x; } int q[31709], tot; bool b[31709]; int gcd(int a, int ...
7
CPP
#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--) { long long int a, b; cin >> a >> b; long long int p = a * b; long long int st = 1; long long int en = 1e6; long long int ans = -1; ...
7
CPP
#include <bits/stdc++.h> using namespace std; using namespace std; int main() { int n; scanf("%d", &n); while (n--) { long long a, b; scanf("%lld%lld", &a, &b); long long c = cbrt(a * b); long long aa = a / c; long long bb = b / c; if (aa * aa * bb == a && bb * bb * aa == b) { puts("...
7
CPP
#include <bits/stdc++.h> using namespace std; const int MAXR = 1000005; long long cubic_root(long long x) { long long l = 0, r = MAXR; while (l != r) { long long m = (l + r + 1) / 2; if (m * m * m > x) r = m - 1; else l = m; } return l; } int main() { int n; scanf("%d", &n); for (i...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = (0); i < (n); i++) { int a, b; scanf("%d%d", &a, &b); int ret = -1; for (int l = 1, r = 1000000, mid = (l + r) >> 1; l <= r; mid = (l + r) >> 1) if (1ll * mid * mid * mid >= 1ll * a * b) r = (ret...
7
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using PII = pair<int, int>; using PLL = pair<ll, ll>; template <typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) { return s << "(" << p.first << ", " << p.second << ")"; } template <type...
7
CPP
#Code by Sounak, IIESTS #------------------------------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() ...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> ...
7
CPP
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return a * b / gcd(a, b); } struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> ...
7
CPP
# ---------------------------iye ha aam zindegi--------------------------------------------- import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction mod = 10 ** 9 + 7 mod1 = 998244353 # ------------------------------warmup---------------------------- impor...
7
PYTHON3
#include <bits/stdc++.h> using namespace std; const long double EPS = 1e-9, PI = acos(-1.); const long long LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll; const int INF = 0x3f3f3f3f, MOD = 1e9 + 7; const int N = 1e6 + 10; map<long long, long long> rt; int q; long long a, b; int main() { for (long long i = 1...
7
CPP
#include <bits/stdc++.h> using namespace std; long long GCD(long long x, long long y) { if (y == 0) return x; return GCD(y, x % y); } long long n, a, b; long long cs; bool calc() { scanf("%lld %lld", &a, &b); long long g = GCD(a, b); long long p = a / g; long long q = b / g; long long pq = p * q; bool r...
7
CPP
#include <bits/stdc++.h> using namespace std; unsigned long long mod = 1e9 + 7; long long MOD = 998244353; unsigned long long ncr(long long n, long long k) { if (k > n) return 1ll * 0; unsigned long long res = 1; if (k > n - k) k = n - k; for (long long i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { long long a, i, x, y; scanf("%I64d ", &a); while (a--) { scanf("%I64d %I64d", &x, &y); i = ceil(cbrt(x * y)); if (x % i == 0 && y % i == 0 && (x * y) == i * i * i) { printf("Yes\n"); } else printf("No\n"); } }
7
CPP
#include <bits/stdc++.h> using namespace std; long long n, a, b; bool check(long long x) { long long l = 0, r = 1000000; while (l != r) { long long m = (l + r + 1) / 2; if (m * m * m > x) { r = m - 1; } else { l = m; } } bool ok = (l * l * l == a * b); return (ok && !(a % l) && !(b...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tc; cin >> tc; while (tc--) { long long a, b; cin >> a >> b; long long pro = (a * b); long long c = cbrt((long double)(pro)); if (c * c * c != pro) cout <...
7
CPP
#include <bits/stdc++.h> long long x, y; long long gcd(long long x, long long y) { if (!y) return x; return gcd(y, x % y); } bool check() { double x2 = log(x), y2 = log(y); double t1 = (2 * y2 - x2) / 3, t2 = (2 * x2 - y2) / 3; t1 = exp(t1); t2 = exp(t2); long long s1 = (t1 + 0.5), s2 = t2 + 0.5; if (fa...
7
CPP
#include <bits/stdc++.h> int main() { int T; scanf("%d", &T); while (T--) { long long x, y; scanf("%I64d%I64d", &x, &y); long long t = x * y; bool flag = false; long long l = 1, r = 1e6 + 10, m; while (l <= r) { m = (l + r) / 2; if (m * m * m == t) { flag = true; ...
7
CPP
#include <bits/stdc++.h> using namespace std; using ll = long long; ll MOD = 1000000007; ll INF = 1LL << 60; ll HI = 1000005; ll cubic_root(ll x) { ll lo = 0, hi = HI; while (lo < hi) { ll m = lo + ((hi - lo + 1) / 2); if (m * m * m > x) hi = m - 1; else lo = m; } return lo; } ll a, b, a...
7
CPP
#include <bits/stdc++.h> using namespace std; const int Maxk = 1005; string mul(string a, string b) { int res[Maxk]; memset(res, 0, sizeof(res)); reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); for (int i = 0; i < a.length(); i++) { for (int j = 0; j < b.length(); j++) { res[i + j] += (a[i...
7
CPP
#include <bits/stdc++.h> using namespace std; signed main() { long long t, a, b; scanf("%lld", &t); while (t--) { scanf("%lld%lld", &a, &b); long long m = pow(a * b, (1.0 / 3)) + 0.5; puts((m * m * m != a * b || a % m || b % m) ? "No" : "Yes"); } }
7
CPP
#include <bits/stdc++.h> using namespace std; template <class T> int getbit(T s, int i) { return (s >> i) & 1; } template <class T> T onbit(T s, int i) { return s | (T(1) << i); } template <class T> T offbit(T s, int i) { return s & (~(T(1) << i)); } template <class T> int cntbit(T s) { return __builtin_popcoun...
7
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); while (n--) { long long int a, b; scanf("%lld %lld", &a, &b); double t = pow(a * b, 1.0 / 3); long long int x = t + 0.0001; if (x * x * x == a * b && a % x == 0 && b % x == 0) printf("YES\n"); else ...
7
CPP
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MOD2 = 1007681537; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while (...
10
CPP
#include <bits/stdc++.h> using namespace std; int n, a[300010]; long long dp[300010][42], ans; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); for (int i = 0; i <= n; i++) for (int j = 0; j <= 30; j++) dp[i][j] = 300000000000LL; dp[0][0] = 0; for (int i = 0; i < n; i...
10
CPP
#include <bits/stdc++.h> const int maxn = 3e5 + 50; const int inf = 0x3f3f3f3f; int n, f[2][312], cur = 0; inline void Update(int& x, int y) { x = std::min(x, y); } int main(int argc, char* argv[]) { scanf("%d", &n); memset(f[cur], 0x3f, sizeof(f[cur])); f[cur][0] = 0; while (n--) { int x, pre = cur; cu...
10
CPP
#include <bits/stdc++.h> using namespace std; void addmod(int &a, long long b) { a = (a + b); if (a >= 1000000007) a -= 1000000007; } void mulmod(int &a, long long b) { a = (a * b) % 1000000007; } template <class T> bool domin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template <class T> bool domax(T &a, ...
10
CPP
#include <bits/stdc++.h> using namespace std; const int N = 300005; int a[N]; int f[45]; int g[45]; int n; int ans; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i] /= 100; memset(f, 127 / 3, sizeof(f)); f[0] = 0; for (int i = 1; i <= n; i++) { memset(g, 127 / 3, sizeof(...
10
CPP
#include <bits/stdc++.h> using namespace std; constexpr long long mod = 1000000007; const long long INF = mod * mod; const long double eps = 1e-12; const long double pi = acos(-1.0); long long mod_pow(long long a, long long n, long long m = mod) { a %= m; long long res = 1; while (n) { if (n & 1) res = res * ...
10
CPP
#include <bits/stdc++.h> using namespace std; template <class T1> void deb(T1 e1) { cout << e1 << endl; } template <class T1, class T2> void deb(T1 e1, T2 e2) { cout << e1 << " " << e2 << endl; } template <class T1, class T2, class T3> void deb(T1 e1, T2 e2, T3 e3) { cout << e1 << " " << e2 << " " << e3 << endl; ...
10
CPP
#include <bits/stdc++.h> using namespace std; int n, sum, tot, ans; int a[400400]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i] / 1000; tot += (a[i] == 1000); } int temp = sum * 10 / 11; if (sum <= 11) temp = sum - a[n] / 1000; if (!tot && temp % 2 == 1) temp--;...
10
CPP
#include <bits/stdc++.h> using namespace std; int n, x, f[3500], g[3500], ans = 1e9, maxn = 3000; int main() { scanf("%d", &n); memset(f, 127, sizeof(f)); f[0] = 0; for (int i = 1; i <= n; i++) { memcpy(g, f, sizeof(f)); memset(f, 127, sizeof(f)); scanf("%d", &x); for (int j = 0; j <= maxn; j +=...
10
CPP
#include <bits/stdc++.h> using namespace std; const int N = 300010; const int M = 31; int n; int a[N]; int d[N][M]; int DP(int i, int bonus) { if (d[i][bonus] != -1) return d[i][bonus]; if (i == n) return max(0, a[i] - bonus); if (bonus > M - 1) return N * M; return d[i][bonus] = min(max(0, a[i] - ...
10
CPP
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; const int INF = 1e9; int n, a[MAXN], f[35], g[35]; int main() { scanf("%d", &n); for (int i = 1; i <= 31; ++i) g[i] = INF; for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); a[i] /= 100; f[0] = f[1] = INF; for (int j = a[i] /...
10
CPP
#include <bits/stdc++.h> using namespace std; int a[300005][45], n, value[300005]; void update(int &x, int y) { x = min(x, y); } int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; i++) { cin >> value[i]; value[i] /= 100; } for (int i = 1; i <= n; i++) for (int j = 0; j < 4...
10
CPP
#include <bits/stdc++.h> const int N = 300010; const int M = 50; const int INF = 0x3f3f3f3f; int dp[N][M], a[N]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &a[i]); a[i] /= 100; } memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; for (int i = 1; i <= n; ++i) { for (...
10
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const long long INF64 = 1e18; const long long MOD = 1e9 + 7; const long double EPS = 1e-9; const long double Pi = 3.1415926535897932384626433832795; const int N = 3e5 + 17; const int M = 32; int dp[N][M]; int main() { int n; cin >> n; vector<int> ...
10
CPP
#include <bits/stdc++.h> using namespace std; template <class T> inline bool getmin(T *a, const T &b) { if (b < *a) { *a = b; return true; } return false; } template <class T> inline bool getmax(T *a, const T &b) { if (b > *a) { *a = b; return true; } return false; } template <class T> inlin...
10
CPP
#include <bits/stdc++.h> const int N = 3e5 + 10; using namespace std; int n, A[N]; int dp[2][50]; int main() { memset(dp, 0x3f, sizeof(dp)); scanf("%d", &n); for (int i = 1; i <= n; ++i) { scanf("%d", &A[i]); A[i] /= 100; } int s = 0, t = 1; dp[0][0] = 0; for (int i = 1; i <= n; ++i) { int a =...
10
CPP
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long INFF = 0x3f3f3f3f3f3f3f3fll; const int MAX = 3e5 + 5; const int MAXN = 1000000; const int MAX_N = MAX; const long long MOD = 1e9 + 7; const long double pi = acos(-1.0); int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } templ...
10
CPP
#include <bits/stdc++.h> using namespace std; const int N = 300000 + 10; long long dp[N][40]; int n; long long a[N]; int main() { memset(dp, 0x3f3f3f3f, sizeof(dp)); scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%I64d", &a[i]); a[i] /= 100; } dp[0][0] = 0; for (int i = 1; i <= n; i++) { ...
10
CPP
#include <bits/stdc++.h> using namespace std; int a[300010]; int dp[300010][70]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } memset(dp, 0x3f3f3f3f, sizeof(dp)); dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 50; j++) if (dp[i][j]...
10
CPP
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 3e5 + 5; int add(int x, int y) { x += y; if (x >= mod) x -= mod; return x; } int mul(int x, int y) { long long z = 1LL * x * y; return z - z / mod * mod; } int a[maxn], b[maxn]; int f[2][55]; void updata(int &x, int y) { x...
10
CPP
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 7; int n, ans, sa, sb, S; int a[N]; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sa += a[i] / 1000, sb += (a[i] == 1000); S = sa * 10 / 11; if (sa <= 11) S = sa - a[n] / 1000; if (sb == 0 && (S & 1)) S--; ...
10
CPP
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') ch == '-' && (f = 0) || (ch = getchar()); while (ch <= '9' && ch >= '0') x = (x << 3) + (x << 1) + ch - '0', ch = getchar(); return f ? x : -x; } int a[300020], f[2][50]; i...
10
CPP
#include <bits/stdc++.h> using namespace std; const int N = 300005, INF = 0x3f3f3f3f; int dp[N][31], s[N], n; int main() { ios::sync_with_stdio(0), cin.tie(0); memset(dp, 0x3f, sizeof(dp)); cin >> n; for (int i = 1; i <= (n); ++i) cin >> s[i], s[i] /= 100; dp[0][0] = 0; for (int i = 1; i <= (n); ++i) { ...
10
CPP
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 99, M = 45, inf = 1e9; int n, t, a[N], dp[N][M], ans = inf; int main() { cin >> n; for (int i = 1; i < n + 1; i++) { cin >> a[i]; a[i] /= 1000; } for (int i = 1; i < M; i++) dp[0][i] = inf; for (int i = 1; i < n + 1; i++) for (int j...
10
CPP