func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 5001; const int B = 27; int zhu[B], n, m; char s[N], t[N]; void solve() { memset(zhu, 0, sizeof(zhu)); n = strlen(s); m = strlen(t); for (int i = 0; i < n; ++i) zhu[s[i] - a ]++; int r = -1, p; if (n > m) p = m; e... |
#include <bits/stdc++.h> using namespace std; inline int read() { char ch = getchar(); int x = 0, f = 1; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while ( 0 <= ch && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; int n, x; int dist[501][501]; bool color[501]; unsigned short num_red; unsigned short ans[501][501][501], best[501][501], sizes[501]; unsigned short inf = ~0; vector<unsigned short> edge[501]; void dfs(unsigned short& now, unsigned short& before) { for... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000,1024000000 ) using namespace std; int main() { int T, i, j, k, ca = 0, n, m; int x1, y1, x2, y2; while (~scanf( %d%d%d%d , &x1, &y1, &x2, &y2)) { scanf( %d , &n); int ans = 0, a, b, c; while (n--) { scanf( %d... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e9 + 7; vector<long long int> v; long long int calcmulti(string s, long long int l, long long int r) { long long int ans = 1; string z = ; for (long long int i = l; i <= r; i++) { if (s[i] == * ) { ans *= stoll(z); ... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { unsigned n(0); cin >> n; vector<unsigned> array(n, 0); for (unsigned it(0); it != n; ++it) { array[it] = it + 1; } --n; for (unsigned it(n); it > 0; --it) { swap(array[it], array[it - 1]); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; cout << a[1] - a[0] << << a[n - 1] - a[0] << endl; for (int i = 1; i < n - 1; i++) cout << min(a[i + 1] - a[i], a[i] - a[i - 1]) << << max(a... |
#include <bits/stdc++.h> using namespace std; long long tab[70]; void Tab() { for (int i = 0; i < 64; i++) tab[i] = pow(2, i); } long long Sum(long long n) { long long m = n + 1; if ((long long)(m) % 2 == 0) m /= 2; else n /= 2; long long sum = m * n; return sum; } long... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:200000000 ) using namespace std; const long long oo = 1LL << 60; const long long kNumMoves = 4; const long long kMoves[kNumMoves][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}}; struct Line { Line() : m(0), c(0) {} Line(long long slope, long long yOr... |
#include <bits/stdc++.h> using namespace std; long long n, in[5100], st[5100], f[5100], ans = 9999999999999; signed main() { cin >> n; for (long long i = 1; i <= n; i++) { cin >> in[i]; } memset(f, 0x7f, sizeof(f)); memcpy(st, in, sizeof(in)); sort(st + 1, st + n + 1); for (long ... |
#include <bits/stdc++.h> using namespace std; double f[4][207][207]; struct node { int x, y; }; node a[207]; bool cmp(const node& x, const node& y) { return x.y > y.y; } int n, m, bm; int main() { while (scanf( %d %d %d , &n, &m, &bm) != EOF) { int i, j, k, r, w; int sum = 0; m... |
#include <bits/stdc++.h> using namespace std; int x, cnt; int main() { cin >> x; while (x > 0) { if (x % 2 == 1) { cnt++; } x /= 2; } cout << cnt << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int num1 = n / 3; long long int num2 = n - (2 * num1); if (num1 % 3 != 0 && num2 % 3 != 0) cout << num1 << << num1 << << num2; else if (num1 - 1 > 0 && (num1 - 1) % 3 != 0 && (num2 +... |
#include <bits/stdc++.h> using namespace std; int n, c[5555], num[5555], ans[5555]; int main() { while (~scanf( %d , &n)) { for (int i = 1; i <= n; i++) scanf( %d , &c[i]); memset(num, 0, sizeof(num)); memset(ans, 0, sizeof(ans)); for (int i = 1; i <= n; i++) { memset(num, 0, s... |
#include <bits/stdc++.h> using namespace std; template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == - ) { ng = true; ch = getchar(); break; } if (ch >= 0 && ch <= 9 ) break; } while (1) { ... |
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define acarr(arr, n, type) type *arr=new type[n]; for(long long i=0; i<n; ++i) cin >> arr[i]; #define ll long long #define TF(ok) cout << (ok ? YES n : NO n ) #define ld long double #define... |
#include <bits/stdc++.h> using namespace std; int x, y; int main() { cin >> x >> y; if (x > 0 && y > 0) cout << 0 << x + y << << x + y << 0 n ; else if (x > 0 && y < 0) cout << 0 << -1 * (x + -1 * y) << << x + -1 * y << 0 n ; else if (x < 0 && y > 0) cout << -1 ... |
#include <bits/stdc++.h> using namespace std; const long long INF = numeric_limits<long long>::max() / 4; struct MinCostMaxFlow { int N; vector<vector<long long> > cap, flow, cost; vector<int> found; vector<long long> dist, pi, width; vector<pair<int, int> > dad; MinCostMaxFlow(int N) ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; scanf( %d %d %d , &a, &b, &c); bool valid = false; int bo1, bo2, bo3; for (int i = 0; i <= a; i++) { bo1 = i; bo3 = a - i; bo2 = c - bo3; if (bo1 + bo3 != a || bo1 + bo2 != b || bo2 + bo3 != c) contin... |
#include <bits/stdc++.h> const int mod = 998244353; const int N = 1e6 + 7; using namespace std; long long n, m, k, i, j, t, sig = 0, ans; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } map<pair<int, int>, set<long long>> mp; long long x[1005], y[1005]; struct node { i... |
#include <bits/stdc++.h> using namespace std; int main() { int q; cin >> q; for (int i = 0; i < q; i++) { int a, b, c; cin >> a; cin >> b; cin >> c; int p1, p2; cin >> p1; cin >> p2; int min_no = min(b, c); if (a <= 1) { cout << 0 << n ; ... |
#include <bits/stdc++.h> using namespace std; int n, m, h, t, u, v, tim, d[100100], w[100100], W[100100]; vector<int> e[100100], ans; int main() { scanf( %d%d%d%d , &n, &m, &h, &t); for (int i = 0; i < m; i++) scanf( %d%d , &u, &v), e[u].push_back(v), e[v].push_back(u); for (int i = 1; i < n +... |
#include <bits/stdc++.h> int main() { int x, y; scanf( %d%d , &x, &y); double r = sqrt(x * x + y * y); int rmin = r; if ((double)rmin == r) { printf( black ); return 0; } if (x == 0 || y == 0) { printf( black ); return 0; } double tan = (double)y / (double)x... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n, m, a, b, g; int dis[N]; long long ans, c[N]; long long sum(int u) { return 1LL * u * (u + 1) / 2; } long long query(int u) { return sum(u / g + 1) * g - 1LL * (u / g + 1) * ((g - ((u + 1) % g)) % g); } int gcd(int u, int v... |
#include <bits/stdc++.h> using namespace std; int n, first, a[1111]; int b[1111], ub = -1, pos; vector<int> c[1111]; vector<int> d; int can[1111]; void go(int p, int v) { if (v == -1) return; if (v == first) ub = p; c[p].push_back(v); go(p, a[v]); } int main() { scanf( %d%d , &n, &... |
#include <bits/stdc++.h> using namespace std; int main() { int n, i, maxi = 0; cin >> n; if (n == 1) { cout << 1 << endl; return 0; } vector<int> a(n, 0); vector<int> right(n, 0); vector<int> left(n, 0); vector<int> ans(n, 0); for (i = 0; i < n; i++) scanf( %d , &a... |
#include <bits/stdc++.h> using namespace std; int n, sum, as, b[100005], len, ia, la; pair<int, int> a[100005]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i].first; a[i].second = i + 1; sum += a[i].first; } sort(a, a + n); la = n / 2; for (int i = 0; ... |
#include <bits/stdc++.h> const double PI = acos(-1); int N; long long A; struct point { long long x, y; } p[100001]; struct line { double start, end; } q[100001]; inline long long sqr(long long x) { return x * x; } inline double tan_360(double x, double y) { if (x == 0) return PI * (y > 0 ... |
#include <bits/stdc++.h> using namespace std; const int M = 1000100; struct node { int w, flag; int a, b; int id; long long num; } a[M]; int n, pos[M], m, s[M]; bool cmp(const node &x, const node &y) { if (x.w == y.w) return x.flag > y.flag; return x.w < y.w; } int fa[M]; bool ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 605; int nask(vector<int> tmp) { if (!tmp.size() || tmp.size() == 1) return 0; cout << ? << tmp.size() << endl; for (int i = (0), iend = ((int)tmp.size() - 1); i <= iend; i++) cout << tmp[i] << ; cout << endl; cout.flus... |
#include <bits/stdc++.h> using namespace std; int n; int a[200010]; int prv[200010]; int f[200010][10]; void FillAll(int l, int r, int x, int y) { for (int i = x, j = l; i <= y; i++) { int ci = (r - j + 1) / (y - i + 1); ci = max(ci, 2); ci = min(ci, 5); for (int jj = j; jj < j +... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int N = 1e6 + 5; long long p[N]; long long cnt[N]; vector<long long> a[N]; long long qmi(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % mod; b >>= 1; a = a ... |
#include <bits/stdc++.h> using namespace std; const int Iinf = 1e9; const long long LLinf = 1e18; const double eps = 1e-6; const long long mod = 1e9 + 7; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(); cout.tie(); int s, x1, x2; cin >> s >> x1 >> x2; int t1, t2; cin >> ... |
#include <bits/stdc++.h> using namespace std; const int n = 1 << 17; double sum[n * 2], lazy_mul[n * 2], lazy_add[n * 2]; void push(int i, int l, int r) { if (lazy_mul[i] != 1 || lazy_add[i] != 0) { sum[i] = sum[i] * lazy_mul[i] + lazy_add[i] * (r - l); if (i < n) { for (int j : {i * 2, ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; int arr[n]; int a = 0, b = 0; for (int i = 0; i < n; i++) { cin >> arr[i]; if (arr[i] == 1) a++; else b++; } vector<pair<int, int>> v(m); for (int i = 0; i < m; i++... |
#include <bits/stdc++.h> using namespace std; int n, m, x, y, f[300010], a[300010][4]; void dfs(int x) { int cnt = 0; for (int i = 1; i <= a[x][0]; i++) cnt += f[x] == f[a[x][i]]; if (cnt > 1) { f[x] ^= 1; for (int i = 1; i <= a[x][0]; i++) if (f[x] == f[a[x][i]]) dfs(a[x][i]); ... |
#include <bits/stdc++.h> using namespace std; string str; int main() { cin >> str; bool chk = false; for (int i = 0; i <= str.length(); i++) { for (char ch = a ; ch <= z ; ch++) { string temp1 = str.substr(0, i) + ch + str.substr(i); string temp2 = temp1; reverse(temp2.... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; const int M = 55; const int K = 200010; const int LIT = 2500; const int INF = 1 << 30; const int dir[6][2] = {{2, 0}, {-2, 0}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}}; bool check(long long x, long long y, long long n) { long long dist =... |
#include <bits/stdc++.h> using namespace std; const int N = 100100; long long n, x; void printbin(long long a) { for (int i = 20; i >= 0; i--) { long long c = a & (1LL << i); cout << bool(c); } cout << n ; } int main() { cin >> n >> x; long long reversed = 0; reversed |... |
#include <bits/stdc++.h> namespace mist { const int W = 103, N = W * W, M = 404; int MOD; long long inv(int x) { return (x == 1 || x == -1) ? x : (-(MOD / x) * inv(MOD % x) % MOD); } struct calculator { int s[M][M]; int n; void reset(int init_n) { n = init_n; memset(s, 0, sizeof(... |
#include <bits/stdc++.h> using namespace std; const int N = 5e2 + 5; const int mod = 1e9 + 7; const long long inf = 1e18; int n, ans, pos, pos1; int un[N], un1[N], cl[N], cl1[N], tr; string t, s; int calc(string e) { un[0] = cl[0] = 0, tr = 0; for (int i = 0; i < n; i++) { if (i) un[i] = u... |
#include <bits/stdc++.h> using namespace std; const int MAXS = 100000; inline long long get(long long n, long long ma, long long b) { return max(ma, (6 * n + b - 1) / b) * b; } int main() { long long n, a, b; cin >> n >> a >> b; if (a * b >= 6 * n) { cout << a * b << endl; cout << ... |
#include <bits/stdc++.h> const int MAXN = 100; int R[2 * MAXN + 2]; int main() { int n, k, i; scanf( %d%d , &n, &k); for (i = 1; i <= 2 * n + 1; ++i) scanf( %d , R + i); for (i = 2; i <= 2 * n && k; ++i) if (R[i - 1] < R[i] - 1 && R[i] - 1 > R[i + 1]) { --R[i]; --k; } ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300010; pair<int, int> c[MAXN]; int n, x[2]; bool check(int pos, int fst, int snd) { int a = c[pos].first; int k = (x[fst] + a - 1) / a; if (pos + k >= n) { return false; } int val = c[pos + k].first; int dk = (x[snd]... |
#include <bits/stdc++.h> using namespace std; string s; int n, m, ans = 0; int main() { cin >> n >> m; while (n--) { cin >> s; } int flag = 0; for (int i = 0; i < s.size(); ++i) { if (s[i] == B ) { flag = 1; } else if (flag) { flag = 0; ans++; ... |
#include <bits/stdc++.h> using namespace std; long long x2, y2; long long euler(long long a, long long b) { if (b == 0) { x2 = 1; y2 = 0; return a; } else { long long res = euler(b, a % b); long long temp = x2; x2 = y2; y2 = temp - (a / b) * y2; return res; ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int MAX = 1e5 + 5; int n, s, h, m; vector<pair<int, int> > a; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> n >> s; for (int i = 0; i < n; i++) { cin >> h >> m; a.push_bac... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) using namespace std; template <class T> using vec = std::vector<T>; bool __hack = std::ios::sync_with_stdio(false); auto __hack1 = cin.tie(nullptr); struct Input { Input(istr... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int add(int a, int b) { a += b; if (a >= MOD) a -= MOD; return a; } int sub(int a, int b) { a -= b; if (a < 0) a += MOD; return a; } char S[1 << 20]; int B[1 << 20], W[1 << 20], X[1 << 20]; int func(int a... |
#include <bits/stdc++.h> using namespace std; long long mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, x; cin >> n >> m >> x; x--; if (n > m) { cout << 0 << endl; return 0; } vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 0)); ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; int s; struct DSU { int p[505]; void init() { for (int i = 1; i <= n; i++) p[i] = i; } int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); } int count() { int count = 0; for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { map<int, int, greater<int>> input; map<int, int, greater<int>> output; map<int, int, greater<int>> input_reverse; map<int, int, greater<int>> output_reverse; int N; scanf( %d , &N); ; int i = N; int index = 1; while (... |
#include <bits/stdc++.h> namespace FastIO { bool IOerror = 0; inline char nc() { static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000; if (p1 == pend) { p1 = buf; pend = buf + fread(buf, 1, 100000, stdin); if (pend == p1) { IOerror = 1; return -1; } ... |
#include <bits/stdc++.h> using namespace std; long long L[100005]; long long P[100005][40]; long long T[100005]; vector<long long> graph[100005]; long long mx = 0, hh; void dfs(long long src, long long par) { if (src == -1) L[par] = 0; else L[par] = L[src] + 1; if (mx < L[par]) { ... |
#include <bits/stdc++.h> using namespace std; template <typename T> int size(T &a) { return (int)a.size(); } template <typename T> T sqr(T a) { return a * a; } const int INF = int(1e9); struct pt { int cnt; long long sumr; long long suml; long long f; int pr; int x; ... |
#include <bits/stdc++.h> using namespace std; int const N = 200001; int main() { long long n, k, d; scanf( %lld%lld%lld , &n, &k, &d); if (d < k) return puts( NO ), 0; long long dv = d / k; if (dv + 1 > n || (dv + (d % k == 0 ? 0 : 2)) > n) return puts( NO ), 0; vector<long long> an; p... |
#include <bits/stdc++.h> using namespace std; long long n, m, p; int q[100010]; long long f[106][100010], D[100010], sum[100010], A[100010], g[100010]; int main() { scanf( %lld %lld %lld , &n, &m, &p); for (int i = 2; i <= n; i++) scanf( %lld , &D[i]), D[i] += D[i - 1]; long long H, T; for (in... |
#include <bits/stdc++.h> using namespace std; int main() { long long int s, x; cin >> s >> x; long long int i, c = 1, f = 0; long long int a = (s - x) / 2; if ((s - x) % 2 != 0) cout << 0; else { for (i = 0; i < 64; i++) { long long int x1 = ((x >> i) & 1); long l... |
#include <bits/stdc++.h> using namespace std; int main() { int i, t, n, m, a[105], ans[105] = {0}; cin >> n >> m; for (__typeof(0) i = 0; i <= m - 1; i++) cin >> a[i]; for (__typeof(0) i = 0; i <= m - 1; i++) { int tem = a[i]; for (int j = tem; j <= n; j++) { if (ans[j] == 0) ans... |
#include <bits/stdc++.h> using namespace std; const int MX = 100000 + 10; long long n, arr[MX]; struct node { long long bit_[3]; node() { memset(bit_, 0, sizeof(bit_)); } }; vector<node> tree; void add(long long inode, long long ptr, long long num) { if (ptr < 0) return; long long q = (num... |
#include <bits/stdc++.h> using namespace std; struct node { long long y, z; long long x; int choice; }; node g[2000001]; int cmp(node head, node a) { if (head.y != a.y) return head.y < a.y; if (head.z != a.z) return head.z < a.z; return head.x > a.x; } struct info { int choice;... |
#include <bits/stdc++.h> using namespace std; int main() { int test; cin >> test; while (test--) { int n, m; cin >> n >> m; string S; cin >> S; vector<int> P(m); vector<int> cnt(n); for (int i = 0; i < m; i++) { cin >> P[i]; cnt[0]++; cnt... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; struct node { long long x, s[8]; int id; } a[N]; int n, p, t; long long f[N][(1 << 8) + 5]; bool cmp(node a, node b) { return a.x > b.x; } int main() { scanf( %d%d%d , &n, &p, &t); for (int i = 1; i <= n; i++) { sc... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fLL; long long N, L, v1, v2, k; long long d; pair<double, double> get_it(double mid) { double end = mid * v2; double pass = mid; for (int i = 1; i < d; i++) { double add = (end... |
#include <bits/stdc++.h> using namespace std; int cd(int a, int b) { return a - a / b; } int main() { int cnt1, cnt2, x, y; cin >> cnt1 >> cnt2 >> x >> y; long long int l = 1, r = 1000000000009; while (l < r) { int mid = l + (r - l) / 2; if (cnt1 <= cd(mid, x) && cnt2 <= cd(mid, y) && ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1e18; template <typename T> void printvector(const vector<T>& foo) { for (auto el : foo) cout << el << ; cout << endl; } bool calc(vector<int>& permuration, const vector<vector<int>>& sets, vector<boo... |
#include <bits/stdc++.h> using namespace std; const int N = 110000; int len, k, n; long long a[N]; long long resolve() { int pK = k; set<pair<long long, int>> av; set<pair<long long, int>> changed; long long sumP = 0; for (int i = 0; i < len; i++) { av.insert({a[i], i}); sumP +... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, k, l, c, d, p, nl, np; cin >> n >> k >> l >> c >> d >> p >> nl >> np; long long totlime = c * d; long long totdrink = k * l; totdrink = totdrink / nl; long long totsalt = p / np; long long mn = min(totlime, totdrin... |
#include <bits/stdc++.h> using namespace std; int n, ans, v[1009], m, c[1009]; vector<int> e; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> v[i]; for (int i = 2; i <= n; i++) { if (v[i] == 0 and v[i - 1] == 1 and v[i + 1] == 1) c[++m] = i + 1; } ans = m; for (int i = 1... |
#include <bits/stdc++.h> using namespace std; int n, ys, ans; int main() { cin >> n; ys = 0; ans = 0; for (int i = n; i > 0; i /= 8) { ys = i % 8; if (ys == 1) ans++; } cout << ans << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; using INT = long long; using pii = pair<int, int>; const int mod = 1e9 + 7; int power(int a, int n, int mod, int ans = 1) { for (; n; n >>= 1, a = (INT)a * a % mod) if (n & 1) ans = (INT)ans * a % mod; return ans; } int fac[3000111], rev[3000111]... |
#include <bits/stdc++.h> int a[(1 << 22) + 1]; int n, m; bool vis[(1 << 22) + 1][2]; bool yes[(1 << 22) + 1]; int mask; void dfs(int now, int p) { if (vis[now][p]) return; vis[now][p] = true; if (p == 0) dfs(now, 1); else { for (int j = 0; j < n; j++) { int jj = 1 << j; ... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 3030; int head[MAX_N], current, n, siz[MAX_N][MAX_N], fa[MAX_N][MAX_N]; long long f[MAX_N][MAX_N]; struct edge { int to, nxt; } edges[MAX_N << 1]; void addpath(int src, int dst) { edges[current].to = dst, edges[current].nxt = head[src... |
#include <bits/stdc++.h> template <class T> inline void read(T &x) { x = 0; register char c = getchar(); register bool f = 0; while (!isdigit(c)) f ^= c == - , c = getchar(); while (isdigit(c)) x = x * 10 + c - 0 , c = getchar(); if (f) x = -x; } template <class T> inline void print(... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const int toN = 58; int pn, p[10000]; int n, a[10000], omask[10000]; int dp[110][1 << 18]; int ans[110][1 << 18]; bool isPrime(int n) { if (n == 2) return true; for (int i = 2; i * i <= n; ++i) if (n % i == 0) return f... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int INF = 0x3f3f3f3f; int dp[N]; struct node { int v, id; } a[N][2]; void up1(int sta, int cost, int i) { if (a[sta][0].v > cost) { a[sta][1] = a[sta][0]; a[sta][0] = {cost, i}; } else if (a[sta][1].v > cost... |
#include <bits/stdc++.h> using namespace std; int n; double vb, vs; double x[105]; double tagx, tagy; double cal(int p) { return sqrt((x[p] - tagx) * (x[p] - tagx) + tagy * tagy); } int cmp(double x) { if (x < (-1e-6)) return -1; else if (x > 1e-6) return 1; else return 0; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; int add(int a, int b) { a += b; return a >= mod ? a - mod : a; } int sub(int a, int b) { a -= b; return a < 0 ? a + mod : a; } int mul(int a, int b) { return (long long)a * b % mod; } int qpow(int a, int b) { in... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int MAXN = 2000 + 5; int dp[MAXN][MAXN] = {0}; int previous[MAXN] = {0}; void calculatePrevious(const string &s, const string &p) { int sSize = s.length(); int pSize = p.length(); for (int i = 0; i < sSize; ++i) {... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, j, i = 0, count = 0, max = 100000000; string s1, s2; cin >> n >> m >> s1 >> s2; vector<int> a, b; while (i + n <= m) { count = 0; for (j = 0; j < n; j++) { if (s1[j] != s2[i + j]) { a.push_back(j +... |
#include <bits/stdc++.h> using namespace std; inline void proc_status() { ifstream t( /proc/self/status ); cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl; } template <typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } t... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const int INF = 0x3f3f3f3f, N = 2000005, M = 2000005, MOD = 1e9 + 7; int sgn(double x) { return x < -eps ? -1 : (x < eps ? 0 : 1); } int Rand(int x) { return rand() * rand() % x + 1; } vector<int> G[N]; int dep[N]; double ans = 0; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:50000000 ) using namespace std; int tt[1000000], kix[1000000], num[1000000], degree[1000000], black[1000000], fix[1000000]; vector<int> q, g[1000000]; int pirveli, p, i, j, n, m, k, a, b; int par[100005][20]; long long ans[1000000]; void go(... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long sum = 0, a; for (int i = 0; i < n; i++) { cin >> a; sum += (i * (a - 1) + a); } cout << sum; } |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long HASH = 1e16 + 7; const long long INF = 1e9; long long tavan(long long a, long long b) { return b ? (tavan(a * a, b >> 1) * (b & 1 ? a : 1)) : 1; } long long gcd(long long a, long long b) { return (a < b) ?... |
#include <bits/stdc++.h> using namespace std; const int Maxl = 26; const int Maxn = 30005; const int Maxstr = 200005; const int Inf = 2000000007; char str[Maxstr]; int t; int n, m, k; int freq[Maxl]; bool dp[Maxn]; int res; int main() { scanf( %d , &t); while (t--) { scanf( %d %d %... |
#include <bits/stdc++.h> using namespace std; namespace { void Solve(int) { const set<string> bins = { AND , OR , XOR }; int n; cin >> n; vector<string> type(n); vector<int> lef(n, -1), rig(n, -1); for (int i = 0, __i = n; i < __i; ++i) { cin >> type[i] >> lef[i]; if (type[i]... |
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100000 + 1; const int INF = numeric_limits<int>::max() / 2; pair<int, int> P[MAX_N]; pair<int, int> prefix[MAX_N], suffix[MAX_N]; int N; long long square(int first) { return 1LL * first * first; } bool valid(long long M) { long long bes... |
#include <bits/stdc++.h> using namespace std; vector<int> a[100010]; int y[100010], res[100010]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n; i++) { int num; scanf( %d%d , &num, &y[i]); res[i] = 0; for (int k = 1; k * k <= num; k++) if (num % k == 0) { ... |
#include <bits/stdc++.h> using namespace std; struct P { long long first, second, sum; P(long long first = 0, long long second = 0, long long sum = 0) : first(first), second(second), sum(sum) {} bool operator<(const P &b) const { return first < b.first; } }; const long long MAX_V = 500100; ... |
#include <bits/stdc++.h> using namespace std; const int Inf = 1e9 + 7; int dp[107][107]; int par[107][107]; string t = .,!? ; bool check(char c) { return t.find(c) == string::npos; } void solve() { int t; cin >> t; for (int k = 0; k < t; k++) { int n; cin >> n; vector<strin... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; long long f = 1; for (long long i = 0; i < 100000; i++) { n += (n % m); if (n % m == 0) { f = 0; break; } } if (!f) cout << Yes << endl; else cout << ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const long long N = 2e5; const long long inf = 1e18; template <typename... T> void read(T&... args) { ((cin >> args), ...); } template <typename... T> void write(T&&... args) { ((cout << args << ), ...); } te... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long data = 0, w = 1; char ch = 0; while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) w = -1, ch = getchar(); while (ch >= 0 && ch <= 9 ) data = data * 10 + ch - 0 , ch = getchar(); retur... |
#include <bits/stdc++.h> using namespace std; int n, used[100003], m[100003]; string s, ans = INFINITE ; void DFS(int v) { if (used[v] == 1) { ans = INFINITE ; return; } used[v] = 1; if (s[v] == < ) { if (v - m[v] > 0) DFS(v - m[v]); else { ans = FINIT... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll t; cin >> t; while (t--) { ll n, m, k; cin >> n >> m >> k; k--; k--; if (m > n * (n - 1) / 2 || m < n - 1) { cout << nO << n ; continue; } if (k > 1) { ... |
#include <bits/stdc++.h> using namespace std; const int M = 10005; vector<int> g[M]; int main() { int n; scanf( %d , &n); for (int i = 0; i < n - 1; i++) { int a, b; scanf( %d %d , &a, &b); g[a].push_back(b); g[b].push_back(a); } int ans = 0; for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; long long fac[1000001]; int main() { long long n, ans = 0, c = 0, mx = 0, tmp, tmp2, lg; cin >> n; for (long long i = 2; i < n; i++) { tmp = n / i; tmp = tmp * (tmp + 1) / 2 - 1; ans += (tmp * 4); } cout << ans << n ; return... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int N; char c[2000000]; int numWays() { if (N == 1) { if (c[0] == * ) return 1; else if (c[0] == 0 ) return 1; else if (c[0] == ? ) return 2; else return 0; } if (c[0] ... |
#include <bits/stdc++.h> using namespace std; constexpr int Mod = 998244353; int n, x, y; int gr[200005]; long long sol; int main() { cin >> n; sol = n; for (int i = 1; i < n; ++i) { cin >> x >> y; gr[x]++; gr[y]++; sol = 1LL * sol * gr[x] % Mod * gr[y] % Mod; } c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.