func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t > 0) { int n; cin >> n; while (n > 0) { cout << 1 << ; n--; } cout << n ; t--; } return 0; } |
#include <bits/stdc++.h> using namespace std; class ST { long long int tree[10000000]; long long int lazy[10000000]; public: void build(int a, int b, int node) { tree[node] = 0; lazy[node] = 0; if (a == b) return; int mid = (a + b + 4000000) / 2 - 2000000; build(a, mi... |
#include <bits/stdc++.h> int main() { int n, amount(0); scanf( %d , &n); bool b[3001] = {false}; int pfactors[3001] = {0}; for (int i = 2; i <= n; ++i) { if (!b[i]) { for (int j = i + i; j <= n; j += i) { b[j] = true; pfactors[j] += 1; } } if (... |
#include <bits/stdc++.h> using namespace std; const int N = 105; const int mod = 1e9 + 7; inline void MOD(int &x) { if (x >= mod) x -= mod; } int n, m, k; int dp[2][N][N][N], C[N][N], r; int ans; int main() { for (int i = 0; i <= 100; i++) { C[i][0] = 1; for (int j = 1; j <= i; j++... |
#include<bits/stdc++.h> using namespace std; /* User Template @Shaurya Gautam CP.cpp */ /*****************************************/ #define ll long long #define vb vector<bool> #define vi vector<int> #define vl vector<long> #define vll vector<long long> #define vpii vector<pair<int, in... |
#include <bits/stdc++.h> using namespace std; int n; vector<int> g[100005]; int c[100005]; double r[100005]; void dfs(int x) { c[x] = 1; for (int i = 0; i < g[x].size(); ++i) { int y = g[x][i]; dfs(y); c[x] += c[y]; } } void calc(int x) { for (int i = 0; i < g[x].size()... |
#include <bits/stdc++.h> using namespace std; int N; int V[100]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int T; cin >> T; while (T--) { int K; cin >> K; const int R = 2 * K + 1; N = 2 * R; int p0 = -1; for (int i = 0; i < N; i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, a, b, c, d, x, y, v, ans = 0; cin >> n >> a >> b >> c >> d; for (long long i = 1; i <= n; i++) { x = a - d + i; v = b - c + i; y = a + b - c - d + i; if ((x > 0 && x <= n) && (y > 0 && y <= n) && (v > 0 && v ... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f, mod = 1000000007; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double pi = acosl(-1.), eps = 1e-9; inline int power(int a, int b, int m = mod, int ans = 1) { for (; b; b >>= 1, a = 1LL * a * a % m) if (b & 1) ans = 1LL * ... |
#include <bits/stdc++.h> using namespace std; int a[100010], ar[100010]; int main() { int n, track = -100002, i; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i]; ar[a[i]] = ar[a[i] - 1] + 1; track = max(ar[a[i]], track); } cout << n - track << endl; } |
#include <bits/stdc++.h> using namespace std; bool compare(pair<int, int> a, pair<int, int> b) { return a.first < b.first; } int main() { float r1, r2, c1, c2, d1, d2; cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2; float a = c1 / 2 + (d1 + r1 - d2 - r2) / 4; float c = c1 / 2 - (d1 + r1 - d2 - r2) / 4; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long Fib[100]; long long Path[100]; pair<long long, long long> get(long long N, long long X, bool f) { assert(Fib[N] >= X); if (N <= 0) { return {0, 0}; } if (N == 1) { if (X == 1) { return... |
#include <bits/stdc++.h> using namespace std; namespace { const double PI = acos(-1.0); } struct Data { int n; int c; vector<int> t; Data() : c(0) {} bool operator<(const Data& d) const { return c < d.c; } }; int main() { int n; while (cin >> n) { n *= 2; Data d[101... |
#include <bits/stdc++.h> using namespace std; inline long long max(long long a, long long b) { return (a > b) ? a : b; } inline long long min(long long a, long long b) { return (a < b) ? a : b; } inline long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } vector<ve... |
#include <bits/stdc++.h> using namespace std; long long int prime[1000010] = {0}; vector<long long int> pr; void sieve() { prime[0] = 1; prime[1] = 1; for (long long int i = 2; i <= sqrt(1000010); i++) { if (prime[i] == 0) { for (long long int j = i * i; j < 1000010; j += i) { ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long arr[n]; for (long long i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); bool f = 1; for (long long i = 1; i < n; i++) { ... |
#include <bits/stdc++.h> int flag[1000001] = {0}, a[1000051][21], ss[100001]; long long qsm(int n, int p) { if (p == 0) return 1; if (p == 1) return n; long long ans = qsm(n, p / 2); if (p % 2) ans = n * ans % 1000000007 * ans % 1000000007; else ans = (ans * ans) % 1000000007; re... |
#include <bits/stdc++.h> using namespace std; bool is_prime(long long n) { for (long long i = 2; i * i <= n; ++i) { if (n % i == 0) { return false; } } return true; } long long getPow(long long a, long long b) { long long res = 1ll, tp = a; while (b) { if (b & 1ll) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string digit[10] = { , one , two , three , four , five , six , seven , eight , nine }; string tenth[10] = { , ten , twenty , thirty , forty , fifty , sixty , ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int x, n, i; cin >> n >> x; long long s = 0, an1 = (-1), an2 = (-1); int a[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { s += a[i];... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T Abs(const T& value) { return value < 0 ? -value : value; } template <typename T> inline T Sqr(const T& value) { return value * value; } const int maxn = 110; int a[maxn][maxn]; int main() { int k; int n = 0;... |
#include <bits/stdc++.h> using namespace std; const int N = 1000 + 9; struct Point { double x, y; Point operator-(const Point& b) const { return (Point){x - b.x, y - b.y}; } } p[N]; double dis2(Point a, Point b) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y); } double dis(Point... |
#include <bits/stdc++.h> using namespace std; int n, i, j, m, x, y; const int N = 1e5 + 7; int t, S, q, ans; int main() { ios_base::sync_with_stdio(false); cin >> t >> S >> q; while (S < t) { S *= q; ans++; } cout << ans; } |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const double PI = acos(-1.0); const double eps = 1e-12; const int MAX = 1000 + 10; const int EDGE = 100000 + 10; struct point { double x, y; point() {} void input() { scanf( %lf%lf , &x, &y); } point(double a, double... |
#include <bits/stdc++.h> using namespace std; const int N = 55, K = 55; int n, k, M, t[K]; int main() { scanf( %d%d%d , &n, &k, &M); long long wholetime = 0; for (int i = 0; i < k; i++) { scanf( %d , &t[i]); wholetime += t[i]; } sort(t, t + k); int ans = 0; for (int whole... |
#include <bits/stdc++.h> using namespace std; int main() { int n; int m; int count; int sum; while (scanf( %d%d , &n, &m) != EOF) { count = 0; sum = 0; if (n == m) { printf( 0 ); printf( n ); continue; } while (n < m) { n = n * 2; ... |
#include <bits/stdc++.h> using namespace std; bool prime[1000001]; const double gr = 1.6180339887; void SieveOfErat(long long int mn) { memset(prime, true, sizeof(prime)); for (long long i = 2; i * i <= mn; i++) { if (prime[i] == true) { for (long long j = i * 2; j <= 1000000; j += i) prim... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.first << << p.second; return os; } template <class T, class U> inline istream& operator>>(istream& os, pair<T, U>& p) { os >> p.first >> p.second; ... |
#include <bits/stdc++.h> using namespace std; using lld = int64_t; struct PT { lld x, y; PT() : x(0), y(0) {} PT(lld a, lld b) : x(a), y(b) {} PT operator-(const PT& a) const { return PT(x - a.x, y - a.y); } }; lld dot(const PT& a, const PT& b) { return a.x * b.x + a.y * b.y; } lld cross(con... |
#include <bits/stdc++.h> using namespace std; struct fastIO { fastIO() {} }; void no() { cout << NO ; exit(0); } void yes() { cout << YES ; exit(0); } const int MAXN = 1e6 * 2; long long n, x, a[MAXN], b[MAXN], m, l, ans, y, z; int main() { if (0) cerr << fixed << setprecis... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int arr[m + 1]; arr[0] = 1; for (int i = 1; i <= m; i++) cin >> arr[i]; long long step = 0; for (int i = 0; i < m; i++) { if (arr[i + 1] < arr[i]) step += (n - arr[i]) + (arr[i + 1] - 1) + 1... |
#include <bits/stdc++.h> using namespace std; const long long SIZE = (long long)1e6 + 50; const long long NUM = 15; const long long TOT = 5; const long long SUM = (long long)1e2 + 50; const long long inf = (long long)1e18 + 50; inline long long read() { long long x = 0, f = 1; char ch = getchar();... |
#include <bits/stdc++.h> using namespace std; const int N = 2005; const int MOD = 1e9 + 7; int a[N][N]; vector<pair<int, pair<int, int> > > vv; int p[N], dist[N][N]; std::vector<pair<int, int> > v[N]; int visit[N]; int root(int x) { while (x != p[x]) { p[x] = p[p[x]]; x = p[x]; } ... |
#include <bits/stdc++.h> using namespace std; int n, a[10]; int MOD = 1000000007; long long C[101][101]; void comb(int lim) { int n, r; C[0][0] = 1; for (n = 1; n <= lim; n++) { C[n][0] = 1; for (r = 1; r <= n - 1; r++) { C[n][r] = (C[n - 1][r - 1] + C[n - 1][r]) % MOD; }... |
#include <bits/stdc++.h> int ar[100000]; int main() { int i, j, m, n, total = 0, a, b, c; scanf( %d %d , &n, &m); if (m == 0 || n == 1) printf( 0 ); else { for (j = 1; j <= m; j++) { scanf( %d %d %d , &a, &b, &c); ar[a] += c; ar[b] -= c; } for (i = 1; ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; const long long INF = (long long)1000000007 * 1000000007; const long double eps = 1e-8; const long double pi = acos(-1.0); int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, 1, -1}; int n, m, t[200010]; set<int> se[200010]; i... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; using ll = long long; template <class t, class u> bool chmax(t& first, u second) { if (first < second) { first = second; return true; } else return false; } template... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b; cin >> a >> b; long long c = abs(a - b); if (a == b) cout << 0 << n ; else { long long ans; if (c % 10 == 0) ans = c / 10; ... |
#include <bits/stdc++.h> using namespace std; int n; int a[109]; int ans; int s; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); s += a[i]; ans = max(ans, a[i]); } for (;; ans++) { if (ans * n - s > s) { printf( %d , ans); ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = 4 * atan(1); const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9 + 7; int nCase = 0; int dcmp(double x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; } templ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int ansx[maxn], ansy[maxn]; int b[maxn], c[maxn]; struct node { int g, p, t, id; node() {} node(int g, int p, int t, int id) { this->g = g; this->p = p; this->t = t; this->id = id; } } a[maxn], i... |
#include <bits/stdc++.h> using namespace std; int main() { int m, r; scanf( %d %d , &m, &r); int i; double sum = 0.0; if (m == 1) printf( %f , 2.0 * r); else if (m == 2) printf( %f , (2.0 + sqrt(2.0) / 2) * r); else { for (i = 2; i <= m - 1; i++) { sum += (i - 1... |
#include <bits/stdc++.h> using namespace std; void solve() {} signed main() { ios::sync_with_stdio(0); cin.tie(0); long long n; cin >> n; deque<long long> dq; for (long long i = 1; i <= n; i++) { long long x; cin >> x; dq.push_back(x); } for (long long i = 1; i <=... |
#include <bits/stdc++.h> using namespace std; int query(int a, int b) { cout << ? << a << << b << endl; fflush(stdout); int tmp; cin >> tmp; return tmp; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int flag = query(0, 0); int a = ... |
#include <bits/stdc++.h> using namespace std; const int NMAX = 1e5 + 4; int a[NMAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int mn = 1e9 + 4; for (int i = 0; i < n; ++i) { cin >> a[i]; mn = min(mn, a[i]); } vector<int> res;... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long x; long long e = 0; long long pos = 0; long long ans = 0; for (long long i = 0; i < n; i++) { cin >> x; e += (pos - x); if (e < 0) { ans += (-1) * e; e = 0; ... |
#include <bits/stdc++.h> using namespace std; int num[6300000]; int main() { int i, j, k; memset(num, 0, sizeof(num)); for (i = 1; i <= 500; i++) num[(i * (i + 1)) / 2] = 1; while (~scanf( %d , &k)) { if (num[k] == 1) printf( YES n ); else printf( NO n ); } retu... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; int counter = 0; int min_c = min(min(a, b / 2), c / 4); counter = 4 * min_c + min_c + min_c * 2; if (c / 4 == 0 || b / 2 == 0) { cout << 0; } else { cout << counter; } return 0... |
#include <bits/stdc++.h> #pragma GCC optimize( -Ofast , -funroll-all-loops ) using namespace std; long long a, k, res; inline long long check(long long x) { while (x) { if (x % 10 == 0) return 1; x /= 10; } return 0; } inline long long f(long long x) { long long res = 0; whi... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int i, n, t, p = INT_MAX, j = 0, x, a = 0, b, l = 0, r = 0, k = 0, e, w = 0; long long sum = 0; string s, m; cin >> n; int ara[n]; int ar[n... |
#include <bits/stdc++.h> using namespace std; const int Win = 3, Loop = 2, Lose = 1; int n, dp[7001][3], ne[3], a[7001][3], k[3], sum[7001][3]; bool b[7001][3]; inline int max(int x, int y) { return x > y ? x : y; } void dfs(int x, int y) { if (b[x][y]) return; b[x][y] = 1; int t = ne[y]; fo... |
#include <bits/stdc++.h> using namespace std; long long power(long long x, long long y, long long m) { if (y == 0) return 1; long long p = power(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; } long long gcd(long long a, long long b) { if (a == 0) return b; ret... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; vector<int> Pr = { 0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103,... |
#include <bits/stdc++.h> using namespace std; namespace fft { struct num { double x, y; num() { x = y = 0; } num(double x, double y) : x(x), y(y) {} }; inline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); } inline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, m; string p, s; vector<int> pos; long long exp(long long a, long long x) { if (x == 0) return 1; long long tmp = exp(a, x / 2); tmp *= tmp; tmp %= MOD; if (x % 2) tmp *= a; tmp %= MOD; retur... |
#include <bits/stdc++.h> using namespace std; double EPS = 1e-9; long long INF = 1000000000000000005ll; double PI = acos(-1); inline string IntToString(long long int a) { char x[100]; sprintf(x, %lld , a); string s = x; return s; } inline long long int StringToInt(string a) { char x[1... |
#include <bits/stdc++.h> using namespace std; const int N = 505, M = 100500; int read(int &n) { char ch = ; int q = 0, w = 1; for (; (ch != - ) && ((ch < 0 ) || (ch > 9 )); ch = getchar()) ; if (ch == - ) w = -1, ch = getchar(); for (; ch >= 0 && ch <= 9 ; ch = getchar()) q = q... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, i, j, k, l, t; cin >> t; while (t--) { cin >> n; vector<int> a(n); for (i = 0; i < n; i++) { cin >> a[i]; } k = 1; long long total = 0; for (i = 0; i < n; i++) { if (k % 2... |
#include <bits/stdc++.h> const long long INF = (1e9 + 12312), MOD = 1e9 + 7; const long double EPS = 0.0000000001; using namespace std; bool ask(long long first, long long second) { cout << first << << second << endl; string s; cin >> s; if (s == Bad ) { exit(1); } return s ==... |
#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... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5100; int N, M; vector<int> edge[MAXN]; int cdist[MAXN][MAXN]; int loc[3]; int target[3]; int eloc; void play(bool finish) { cout << loc[0] + 1 << << loc[1] + 1 << << loc[2] + 1 << n ; cout << flush; if (!finish) { ... |
#include <bits/stdc++.h> using namespace std; map<string, int> m; int main() { int n; cin >> n; string x, y; for (int i = 0; i < n; i++) { cin >> x >> y; m[y]++; } int t1, t2, temp, temp1; t1 = m[ hard ]; t2 = m[ soft ]; if (t1 > t2) { temp = t1; t1 = t2... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) using namespace std; const int N = 1e3 + 7; const int SZ = 1e6 * 14; int val[SZ]; pair<int, int> ans; int A[N], X[N], vis[N], maxind; void solve(int need, int pos, int mask = 0, int sum = 0) { if (pos > maxind) { if (need != 0) return; ... |
#include <bits/stdc++.h> using namespace std; int main() { int tc, w, h, flag = 0, a, b; cin >> tc; for (int i = 1; i <= tc; i++) { cin >> w >> h; if (w > h) swap(h, w); if (i > 1) { if (b < h && b >= w) { int t = w; w = h; h = t; } else if... |
#include <bits/stdc++.h> using namespace std; int n, m, a[555][555], e[555][555], s, ans = -1e9; int sum(int x, int y, int xx, int yy) { return e[xx + 1][yy + 1] - e[x][yy + 1] - e[xx + 1][y] + e[x][y]; } int main() { cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) sca... |
#include <bits/stdc++.h> using namespace std; inline int read() { int f = 1, x = 0; char ch; do { ch = getchar(); if (ch == - ) f = -1; } while (ch < 0 || ch > 9 ); do { x = (x << 3) + (x << 1) + ch - 0 ; ch = getchar(); } while (ch >= 0 && ch <= 9 ); retu... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100005; const int maxm = 2000005; const int inf = 0x3f3f3f3f; const int mod = 1000000000 + 7; void init() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); }; int n, m; vector<int> v[100005]; vector<int> vv[100005]; i... |
#include <bits/stdc++.h> using namespace std; char buffer[1048576]; int main() { scanf( %s , buffer); string dat(buffer); int n = dat.length(); int Q; scanf( %d , &Q); int lgstep = 1; while ((1 << lgstep) <= n) lgstep++; while (Q--) { int k, d; scanf( %d%d , &k, &d); ... |
#include <bits/stdc++.h> using namespace std; int main() { vector<string> a; vector<string> z; string s; while (cin >> s) { a.push_back(s); } int ans = 0; sort(a.begin(), a.end()); for (int r = 0; r < 720; r++) { if (a[0].length() + a[5].length() == a[3].length() + 1 && ... |
#include <bits/stdc++.h> using namespace std; long long n, m, q; long long b[100000 + 1]; long long suma; long long sums; long long sum[100000 + 1]; long long sign(long long i) { return ((i & 1) ? 1 : (-1)); } inline long long poz(long long a) { return (a > 0 ? a : (-a)); } void readFile() { scanf... |
#include <bits/stdc++.h> int dr[] = {2, 2, -2, -2, 1, -1, 1, -1}; int dc[] = {1, -1, 1, -1, 2, 2, -2, -2}; int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1}; int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1}; int dr2[] = {0, 0, 1, -1}; int dc2[] = {1, -1, 0, 0}; using namespace std; long long a[100005]; long long bigmod(... |
#include <bits/stdc++.h> using namespace std; const int kMod = 1e9 + 7; const int kNmax = 2e5 + 10; int n, v[kNmax], sub[kNmax], up[kNmax][2], down[kNmax][2], res, res_even; vector<int> g[kNmax]; void dfs(int node, int father = 0) { sub[node] = 1; down[node][0] = 1; int ways = (1LL * n * n) % kM... |
#include <bits/stdc++.h> using namespace std; int main() { vector<int> bariers; int n, m, s, d, temp; scanf( %d%d%d%d , &n, &m, &s, &d); for (int i = 0; i < n; i++) { scanf( %d , &temp); bariers.push_back(temp); } sort(bariers.begin(), bariers.end()); int sing_dist, temp_dist... |
#include <cstdio> #include <algorithm> #include <vector> #include <set> #include <cstdlib> #include <utility> #include <cmath> #include <queue> #include <stack> #include <cstring> using namespace std; #define ll long long #ifndef ONLINE_JUDGE #define debug(format, ...) fprintf(stderr,... |
#include <bits/stdc++.h> using namespace std; int n; double r, v; double a, b; bool check(double l) { double arfa = l / r; double A = r * (1 - cos(arfa)); double B = r * sin(arfa); return l + sqrt(A * A + B * B) >= b - a; } int main() { cin >> n >> r >> v; while (n--) { scanf... |
#include <bits/stdc++.h> using namespace std; using namespace std; const int maxn = 3e5 + 7; int n, f[maxn][20], dep[maxn]; set<int> s1, s2; int mx = 0; long long ans = 0; int path(int o, int p) { if (dep[o] < dep[p]) swap(o, p); int dis = dep[o] - dep[p]; for (int i = 19; i >= 0; --i) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, max = 0, max2 = 0, indexm, indexm2; cin >> n; for (int i = 0; i < n; i++) { int temp; cin >> temp; if (temp >= max) { max2 = max; indexm2 = indexm; max = temp; indexm = i + 1; } else... |
#include <bits/stdc++.h> using namespace std; template <typename T> void maxtt(T& t1, T t2) { t1 = max(t1, t2); } template <typename T> void mintt(T& t1, T t2) { t1 = min(t1, t2); } bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long... |
#include <bits/stdc++.h> using namespace std; int main() { int k, l, m, n, d; int cont = 0; cin >> k >> l >> m >> n >> d; cont = d; if (k == 1 || l == 1 || m == 1 || n == 1) { cout << d << endl; } else { for (int i = 1; i <= d; i++) { if ((i % k != 0) && (i % l != 0) && (... |
#include <bits/stdc++.h> using namespace std; long long ans = 0; int main(int argc, char const *argv[]) { int t; cin >> t; while (t--) { int a, b, ans = 0; cin >> a >> b; if (a == b) cout << (a * 2) / 3 << endl; else { if (a > b) swap(a, b); if (b >= 2 *... |
#include <bits/stdc++.h> using namespace std; int getint() { int x = 0; char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); while (c >= 0 && c <= 9 ) x *= 10, x += (c - 0 ), c = getchar(); return x; } vector<pair<int, int> > ans; int n, m, tag; int a[40][40], b[40][40], cnt... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n; cin >> n; long long ans = 0; while (n % 2 == 0) { n /= 2; ans++; } while (n % 3 == 0) { n /= 3; ans += 2; } while (n % 5 ... |
/** * created: 06/03/2021, 16:16:13 **/ #include <bits/stdc++.h> using namespace std; const int max_n = 100111, inf = 1000111222; const int max_c = 26; int t, n, k, cnt[max_c], need[max_c]; char s[max_n]; bool check(int mx) { int tot = 0; for (int i = 0; i < max_c; ++i) { ... |
#include <bits/stdc++.h> using namespace std; struct point { double x, y; }; point operator+(point a, point b) { return (point){a.x + b.x, a.y + b.y}; } point operator*(point a, double b) { return (point){a.x * b, a.y * b}; } double len(point x) { return sqrt(x.x * x.x + x.y * x.y); } void print(point... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, k; cin >> n >> k; if (k == 1) { long long int ans = n * (n - 1) / 2; cout << ans << << ans << endl; } else { long long int ans = (n - k + 1) * (n... |
#include <bits/stdc++.h> using namespace std; const int Mod = (int)1e9 + 7; const int MX = 1073741822; const long long MXLL = 4e18; const int Sz = 1110111; inline void Read_rap() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline void randomizer3000() { unsigned int seed;... |
#include <bits/stdc++.h> const int N = 41; long long bin_p(long long a, long long b) { if (!b) return 1; if (b % 2 == 0) { long long cur = bin_p(a, b / 2); return cur * cur; } return a * bin_p(a, b - 1); } long long color[N]; std::vector<long long> g[N]; long long g1[N], cmpSz = ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100010; int ans = -1, ansd, a[MAXN], b[MAXN], n, m; inline int Pow(int x, int y, int mod) { int s = 1; for (; y; y >>= 1, x = 1ll * x * x % mod) if (y & 1) s = 1ll * s * x % mod; return s; } inline bool find(int *a, int n, int ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, i; while (scanf( %lld %lld , &n, &k) != EOF) { vector<long long int> v; for (i = 1; i * i <= n; i++) { if (n % i == 0) { v.push_back(i); if ((n / i) != i) v.push_back(n / i); } ... |
#include <bits/stdc++.h> char S[1000000 + 5], T[1000000 + 5]; int c[1000000 + 5][26], l[1000000 + 5], f[1000000 + 5], tn, df[1000000 + 5], ff[1000000 + 5], s[1000000 + 5], F[1000000 + 5]; int main() { int n, i, j, x; scanf( %s , S + 1); n = strlen(S + 1); T[0] = 255; for (i = 1; i <= n /... |
#include <bits/stdc++.h> using namespace std; void solve() { int i, j, n, ct = 0; cin >> n; int a[n]; for (i = 0; i < n; i++) cin >> a[i]; if (n < 2) { cout << -1 n ; return; } sort(a, a + n); set<int> ans; if (n == 2) { ans.insert(a[1] + a[1] - a[0]); an... |
#include <bits/stdc++.h> using namespace std; int main() { long long int i, j, k, l, m, n; cin >> n; string s[n], t; for (i = 0; i < n; i++) { cin >> s[i]; } map<string, vector<long long int>> mp; set<string> ss; for (i = 1; i <= 9; i++) { for (j = 0; j < n; j++) { ... |
#include <bits/stdc++.h> using namespace std; string ToStr(char k) { stringstream ss; ss << k; return ss.str(); } bool check(string str) { int n = (int)str.length(); for (int i = 0; i < n / 2; i++) { if (str[i] != str[n - i - 1]) return false; } return true; } int main() { ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 1000 * 101; const long long INF = 1e18; long long n, a[maxn]; vector<pair<char, long long> > ans1; vector<pair<long long, long long> > ans; queue<long long> bra; int main() { std::ios::sync_with_stdio(0); cin.tie(0); cout.t... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, kMaxP = 3000007, kMaxN = 200007, root = 15311432, root_1 = 469870224, root_pw = 1 << 23; long long binpow(long long a, long long b) { a %= mod; long long res = 1; while (b > 0) { if (b & 1) res = res * a % mod; ... |
#include <bits/stdc++.h> using namespace std; bool gone[1000000]; int n; int ord[1000000], put[1000000]; int main() { scanf( %i , &n); for (int(a) = 0; (a) < (n); (a)++) scanf( %i , ord + a); for (int(a) = 0; (a) < (n); (a)++) scanf( %i , put + a); int i = 0; for (int(a) = 0; (a) < (n); (a... |
#include <bits/stdc++.h> enum { MAXN = 102 }; int reverse[MAXN], target[MAXN], init[MAXN]; int n; int eq(int *a, int *b) { int i; for (i = 1; i <= n; i++) if (a[i] != b[i]) return 0; return 1; } void proc(int *a, int *b) { int ans[MAXN], i; for (i = 1; i <= n; i++) { ans[i] =... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int R[N], czy[N], dp[N], siz[N]; pair<int, int> E[N], E2[N]; int M; pair<int, int> Find(int x) { if (x == R[x]) return {x, 0}; pair<int, int> a = Find(R[x]); a.second ^= czy[x]; return a; } void Union(int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long pw[19]; long long val[19]; char A[100009]; string s[100009]; int main() { scanf( %s , A); scanf( %d , &m); for (int i = 0; i < 10; i++) { val[i] = i; pw[i] = 10; } for (int i = 0; i < m; i++) cin >> s[i]; ... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = (((1 << 30) - 1) << 1) + 1; const int nINF = 1 << 31; string s; vector<int> v[2], ans; int n, t; void print(vector<int>& vec) { for (int x : vec) cout << x << ; cout... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.