func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long long MOD_EXPO(long long b, long long p, long long m) { if (p == 0) return 1; long long ret = MOD_EXPO(b, p / 2, m) % m; ret = (ret * ret) % m; return ((p & 1) ? (ret * b) % m : ret % m); } long long POWER(long long N, long long K) { long lon... |
#include <bits/stdc++.h> using namespace std; int main() { int x, k = 0; cin >> x; while (x) { k += x % 2; x /= 2; } cout << k; } |
#include <bits/stdc++.h> using namespace std; const int MaxN = 1005; char a[MaxN]; int b[MaxN]; bool prime(int x) { for (int i = 2; i < x / 2; i++) { if (x % 2 == 0) { return false; } } return true; } int main() { string s; int i, n, Max, j; char v; Max = 0;... |
#include <bits/stdc++.h> using namespace std; int t, i; int c[32650]; void ciu(); unsigned long long int p, q; unsigned long long int minim = 0xffffffffffffffff; vector<unsigned long long int> v; int main() { cin >> t; ciu(); while (t--) { minim = 0xffffffffffffffff; cin >> p >> ... |
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } inline long long mx(long long a, long long b) { if (a > b) return a; else return b; } long long gc... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m; cin >> n >> m; long long a = n, b = m; while (1) { if (a <= 0 || b <= 0) break; if (a >= 2 * b) { a %= 2 * b; continue; } if (b >= 2 * a) { b %= 2 * a; continue; }... |
#include <bits/stdc++.h> using namespace std; int main() { long long int l, r, k; cin >> l >> r >> k; if (k == 1 || l == r || (r - l == 1 && l % 2 && (l ^ r) >= l)) { cout << l << n1 n << l << endl; return 0; } long long int num = 1, ind; for (int i = 0;; i++) { if (num ... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5, MOD = 1e9 + 7; char s[N], buf[1 << 20]; int ppp, qqq; inline char gc() { if (ppp == qqq) ppp = 0, qqq = fread(buf, 1, 1 << 20, stdin); return buf[ppp++]; } inline void rs() { char x; int t = 0; while ((x = getchar()) ... |
#include <bits/stdc++.h> using namespace std; string s; vector<int> v; int main(int argc, char const *argv[]) { cin >> s; int n = s.size(); sort(s.begin(), s.end()); for (int i = 0; i < n; i++) { if (s[i] > 0 ) { swap(s[0], s[i]); break; } } string q; cin... |
#include <bits/stdc++.h> using namespace std; int main() { int arr[105]; int n; cin >> n; for (int x = 0; x < n; x++) { cin >> arr[x]; } sort(arr, arr + n); for (int x = 0; x < n; x++) { cout << arr[x] << ; } } |
#include <bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &item) { out << ( << item.first << , << item.second <... |
#include <bits/stdc++.h> using namespace std; typedef bool mat[55][55][35]; mat adja, adjb; char a[55], b[55], x[55], y[55], z[55]; int dp[55][55], k; inline void upd(int &u, int v) { u = min(u, v); } inline void work(char *str, int n, mat adj) { memset(adj, false, 55 * 55 * 35); for (int i = 0; i... |
#include <bits/stdc++.h> using namespace std; int P1, P2, P3, T1, T2; int interval(int r, int l) { int t = l - r; int sum = 0; if (t > T1) { sum = T1 * P1; t = t - T1; if (t > T2) { sum = T2 * P2 + sum; t = t - T2; sum = sum + t * P3; } else { su... |
#include<bits/stdc++.h> #define int long long using namespace std; const int mod=1e9+7; const int N=3e5+100; int fa[N]; //并查集,表示i的祖父fa[i] int begi; //记录可以随意放的点的位置(只有一个) int n,m; int a[N],b[N],c[N],in[N],ans[N]; //a[i]和b[i]表示i必须在a[i]的左边,b[i]的右边 //c[i]表示在缩成一个点的一段中的开头(b[i]的限制中能无限制的放位置) //in[i]表示入... |
#include <bits/stdc++.h> using namespace std; int main() { int t; t = 1; while (t--) { long long int n; cin >> n; long long int arr[n + 1]; long long int ans[n + 1]; unordered_map<long long int, long long int> mp; arr[0] = 0; for (__typeof(n + 1) i = (1) - ((1) ... |
#include <bits/stdc++.h> using namespace std; long long pw(long long base, long long e) { return e ? pw(base * base, e / 2) * (e % 2 ? base : 1) : 1; } const int maxn = 1e6 + 10, mod = 1e9 + 7, maxlg = 21, lim = 1e6; const long long INF = 1e9; long long fen[maxn]; vector<int> r[maxn]; int n; int a... |
#include <bits/stdc++.h> using namespace std; int k, d, sk, t; void sp(int t) { for (int j = 0; j < k; j++) { d = k / 2 + j % 2; sk = j % 2; if (t % 2 == 0) { while (d > sk) { if (d % 2 == 0) { printf( bb ); } else { printf( ww ); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long sumx = 0; long long sumy = 0; for (long long i = 0; i < n; i++) { long long a, b; cin >> a >> b; sumx += a; sumy += b; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n; cin >> n; long long arr[n + 5], mx = 0, mn = INT_MIN; for (int i = 0; i < n; i++) cin >> arr[i]; if (arr[n - 1] > 0) arr[n] = -1; else arr[n] =... |
#include <bits/stdc++.h> using namespace std; struct SegmentTreeLazy { typedef long long T; const T inf = (T)1e18; const T not_found = -2; SegmentTreeLazy(vector<T> &v) { n = static_cast<int>(v.size()); int pow2 = 1; while (pow2 < n) pow2 <<= 1; mx.resize(2 * pow2, -inf); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 4e5; vector<long long> coords; vector<pair<pair<long long, bool>, pair<long long, long long> > > sweep; map<long long, long long> ind; struct nodo { int may, pos; }; struct segTree { int n, h, d[N]; nodo t[N << 1]; void in... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; int dx[5] = {0, 1, 0, -1, 0}; int dy[5] = {0, 0, 1, 0, -1}; int n, b, q; int a[N + 5][N + 5]; int nx[N * N * 5 + 55][2]; int ans[111111]; long long t[111111]; int hash1(int x, int y, int d) { if (a[x][y]) d = a[x][y]; return d... |
#include <bits/stdc++.h> using namespace std; const int N = 3E4 + 5; const int M = 500; int n, d, a[N], x, ans, r, L, w, f[N][M * 2 + 5]; int main() { cin >> n >> L; for (int i = 1; i <= n; i++) scanf( %d , &r), a[r]++; memset(f, -10, sizeof(f)); f[L][M] = a[L]; for (int i = 1; i <= r; i++... |
#include <bits/stdc++.h> using namespace std; vector<pair<int, char> > vec[103]; bool dp[103][103][2][300]; bool declared[103][103][2][300]; bool f(int u1, int u2, int turn, char round) { if (declared[u1][u2][turn][round]) return dp[u1][u2][turn][round]; if (turn == 1) { for (int i = 0; i < vec[... |
#include <bits/stdc++.h> using namespace std; const long long mx = 223456; long long n, a[mx], b[mx], sum1, sum2, ca, cb; int32_t main() { cin >> n; for (long long i = 0; i < n; i++) { cin >> a[i]; } for (long long i = 0; i < n; i++) { cin >> b[i]; } sort(a, a + n); sort(... |
#include <cstdio> #include <cassert> #include <utility> #include <functional> #define X first #define Y second const int mod = 998244353; template<int k> struct node{ node <k-1>* chd[2]; int cnt; int lazy; int has[2]; int get_cnt(){ assert(this!=NULL); return cnt; } ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long double a, b, c; cin >> a >> b >> c; vector<int_fast64_t> am; int_fast64_t k = 1, max = pow(10, 9); int_fast64_t f = pow(k, a) * b + c; while (k <= 81 && f <= max) { int_fas... |
#include <bits/stdc++.h> using namespace std; using lli = int64_t; const int maxN = 100010; vector<int> adj[maxN]; int input[maxN]; bool visited[maxN]; int cost = INT_MAX; void dfs(int node) { visited[node] = true; cost = min(cost, input[node]); for (auto child : adj[node]) { if (!visi... |
#include <bits/stdc++.h> using namespace std; const int SIZE = 200010; const long long INF = 1e17; const long long INF_half = 1e16 + 1e10; struct data { long long v, c; data(long long _v = 0, long long _c = 0) : v(_v), c(_c) {} bool operator<(const data& b) const { return c < b.c || (c == b.... |
#include <bits/stdc++.h> using namespace std; int max(int a, int b) { if (a > b) return a; else return b; } int main() { long int x, y, z, w, mx; cin >> x >> y >> z >> w; mx = max(w, max(z, max(x, y))); if (mx == w) { cout << (mx - z) << << (mx - y) << << (mx - ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, f1; int b[100005], i, j; scanf( %d%d , &n, &m); map<int, int> Q, q; for (i = 1; i <= n; i++) { scanf( %d , &f1); q[f1]++; Q[f1] = i; } for (i = 1; i <= m; i++) { scanf( %d , &b[i]); } int... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 100; char s[N]; int n, m, t[N]; int a[N * 4], b[N * 4], ab[N * 4], ba[N * 4], aba[N * 4], tag[N * 4]; void pushup(int now) { a[now] = max(a[(now << 1)], a[(now << 1 | 1)]); b[now] = min(b[(now << 1)], b[(now << 1 | 1)]); ab[now] =... |
#include <bits/stdc++.h> using namespace std; const int N = 1e9 + 1; const long double pi = 3.1415926535897; void solve() { int n, ans(0); cin >> n; int a[n], b[5001] = {0}; for (int i = 0; i < n; i++) { cin >> a[i]; if (b[a[i]] == 0) b[a[i]] = 1; } for (int i = 1; i < n + 1;... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x = 0, i, j; vector<pair<int, int> > v; map<int, vector<int> > mp; map<int, vector<int> >::iterator it; scanf( %d %d , &n, &m); for (i = 0; i < m; i++) { int x, y; scanf( %d %d , &x, &y); x--; y--; ... |
#include <bits/stdc++.h> using namespace std; int marcg[112], marcb[112], n, m, b, g, xi; int main() { scanf( %d %d , &n, &m); scanf( %d , &b); for (int i = 0; i < b; i++) { scanf( %d , &xi); marcb[xi] = 1; } scanf( %d , &g); for (int i = 0; i < g; i++) { scanf( %d , &xi)... |
#include <bits/stdc++.h> using namespace std; char arr[500001]; char inv(char temp) { if (temp == 0 ) return 1 ; return 0 ; } string invert(string temp) { int n = temp.length(); if (n % 2 == 1) { for (int i = 1; i < n; i += 2) temp[i] = inv(temp[i]); } else { for (int i = 1;... |
#include <bits/stdc++.h> using namespace std; long long i, j; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, d; cin >> n >> d; string s; cin >> s; long long p = 0, tot = 0; while (1) { long long f = 0; for (i = min(p + d, n - 1); i ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int A[n + 1], S[n + 1], S1[n + 3]; A[0] = 0; for (int i = 1; i <= n; i++) { cin >> A[i]; } S[0] = 0; for (int i = 1; i <= n; i++) { S[i] = S[i - 1] + A[i]; } string st; cin >> st; ... |
#include <bits/stdc++.h> template <typename T, typename S> inline bool upmin(T& a, const S& b) { return a > b ? a = b, 1 : 0; } template <typename T, typename S> inline bool upmax(T& a, const S& b) { return a < b ? a = b, 1 : 0; } using namespace std; const int dx[4] = {-1, 0, 1, 0}; const int... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int MAXN = 1e6; int solve(int a, int b, int c) { if (b < a) swap(a, b); int dis = b - a; int statr = 1; int all = dis * 2; int res = 0; if (a - dis >= 1 || c > 2 * dis) return -1; if (c > dis) res = c - d... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, q; cin >> n >> m; if (m) q = min(m, n - m); else q = 1; cout << q << endl; } |
#include <bits/stdc++.h> using namespace std; int n, mn = 200, c = 0, x, y, i; int main() { cin >> n; for (i = 0; i < n; i++) { cin >> x >> y; mn = min(mn, y); c += x * mn; } cout << c; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int n; pair<int, int> Cd[N + 10]; int cop[2 * N + 10], lnk[2 * N + 10]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d , &Cd[i].first), Cd[i].second = i * 2 - 1; sort(Cd + 1, Cd + 1 + n); int L = 1, ... |
#include <bits/stdc++.h> using namespace std; typedef pair<long long, long long> ll; typedef vector<long long> vl; typedef vector<ll> vll; typedef vector<vl> vvl; template <typename T> ostream &operator<<(ostream &o, vector<T> v) { if (v.size() > 0) o << v[0]; for (unsigned i = 1; i < v.size(); i+... |
#include <bits/stdc++.h> #pragma GCC target( sse,sse2,sse3,ssse3,sse4,avx ) using namespace std; const int MAXSIZE = 10000020; int bufpos; char buf[MAXSIZE]; void init() { buf[fread(buf, 1, MAXSIZE, stdin)] = 0 ; bufpos = 0; } int readint() { int val = 0; for (; !isdigit(buf[bufpos]); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; long long sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum +... |
#include <bits/stdc++.h> using namespace std; const int N = 100100; int main() { string s, ans; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == . ) ans += 0 ; if (s[i] == - ) { i++; if (s[i] == . ) ans += 1 ; else ans += 2 ; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); int ans = ((l + 1) * 26) - l; cout << ans; return 0; } |
#include <bits/stdc++.h> using namespace std; mt19937 mt_rand(time(0)); const int N = 3e5 + 5; int q, n, s[N], maks[N], dp[N]; map<int, int> mapa[N]; int main() { scanf( %d , &q); while (q--) { scanf( %d , &n); for (int i = 0; i < n; i++) scanf( %d , &s[i]); for (int i = 0; i < n; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 1e5 + 5; ll x; string s; int ans[MAXN]; void init() { ; ; } void solve(int casei) { ll n = s.length(); s = # + s; for (int i = 1; i <= n; ++i) { ans[i] = -1; } for (int i = 1; i <= ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int v[N]; int n, k; int main() { scanf( %d %d , &n, &k); n--; for (int i = 1; i <= n; ++i) scanf( %d , v + i), v[i] += v[i - 1]; int ans = 0x3F3F3F3F; for (int i = k; i <= n; ++i) ans = min(ans, v[i] - v[i - k]); print... |
#include <bits/stdc++.h> using namespace std; long long int a, b, c, l, ans; long long int rec(long long int A, long long int B, long long int C, long long int L) { if (A < B + C) { return 0; } long long int d = min(L, A - B - C); return ((d + 1) * (d + 2)) / 2; } int... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> std::istream& operator>>(std::istream& i, pair<T, U>& p) { i >> p.first >> p.second; return i; } template <typename T> std::istream& operator>>(std::istream& i, vector<T>& t) { for (auto& v : t) { i >> v; }... |
#include <bits/stdc++.h> using namespace std; long long a, b; long long res = 0LL; int mod = 1000000007; int main() { cin >> a >> b; cout << (((((((((a * (a + 1)) / 2 % mod) * (b % mod)) % mod) + a) % mod) % mod) * ((b * (b - 1)) / 2 % mod)) % mod) <<... |
#include <bits/stdc++.h> using namespace std; const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const long long linf = 4000000000000000000LL; const long long inf = 998244353; const long double pi = 3.1415926535; long long maximum(long long x, long long y) { if (x > y) return x; return y; } ... |
#include <bits/stdc++.h> using namespace std; int dp[5050][5050], q[5050][5050]; int ans[5050], len; char s[5050]; void init() { for (int i = 0; i < len; i++) { int l = 0; while (i - l >= 0 && i + l < len && s[i - l] == s[i + l]) dp[i - l][i + l] = 1, l++; l = 0; while (i -... |
#include <bits/stdc++.h> using namespace std; int read() { int x = 0, f = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) f = -1; c = getchar(); } while (c >= 0 && c <= 9 ) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar(); return x * f; } int n, a,... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2010; int n, ans; double x[maxn], y[maxn]; int main() { scanf( %d , &n); for (int i = 1, a, b, c; i <= n; i++) { scanf( %d %d %d , &a, &b, &c); x[i] = 1.0 * a * c / (a * a + b * b); y[i] = 1.0 * b * c / (a * a + b * b); ... |
#include <bits/stdc++.h> int map[55][55]; int to[55][55][4][2]; int rx[] = {0, -1, 0, 1}; int ry[] = {1, 0, -1, 0}; struct node { int x, y, dp, cp; }; int main() { memset(map, 0, sizeof(map)); int n, m, step, i, j; char str[55]; node now; now.x = 1, now.y = 1; now.dp = 0, now.c... |
#include <bits/stdc++.h> using namespace std; bool si[1000007]; int x0 = 1000007; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int x2; cin >> x2; si[0] = si[1] = false; for (int i = 2; i < 1000007; i++) { si[i] = true; } for (int i = 2; i < 10... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; int n; cin >> s; n = s.size(); s = s + b ; for (int i = 0; i < n; i++) { cout << (s[i] != s[i + 1] ? 1 : 0) << ; } ... |
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> a(N); for (int i = 0; i < N; ++i) { scanf( %d , &a[i]); } sort(a.begin(), a.end()); int res = 0; for (int i = 0; i <= N; ++i) { if (a[i] == a[i + 1]) { ++res; ++i; ... |
#include <bits/stdc++.h> using namespace std; bool bi[12][12]; int main() { int a, b, c, d, e, x, y, z, n, k, N, M; scanf( %d %d , &N, &M); scanf( %d %d , &z, &k); for (a = 0; a < z; a++) { scanf( %d %d , &x, &y); bi[x][y] = true; } z = 0; for (a = 1; a <= N; a++) { f... |
#include <bits/stdc++.h> using namespace std; int main() { long int mx = 0, n; cin >> n; vector<long int> vec; for (int i = 0; i < n; i++) { long int x; cin >> x; vec.push_back(x); } if (vec.size() == 1) { cout << 1 << endl; return 0; } for (int i = 0;... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; scanf( %d%d%d , &a, &b, &c); for (int i = 1, _b = a; i <= _b; i++) { int j = a / i; if (b % i == 0 && c % j == 0 && b / i == c / j) { printf( %d n , 4 * (i + j + b / i)); return 0; } } } |
#include <bits/stdc++.h> using namespace std; int main() { int tt = 1; while (tt--) { int n; cin >> n; int a[n - 1]; cout << ? 2 3 << endl << endl; int m; cin >> m; for (int i = 0; i < n - 1; i++) { cout << ? << 1 << << i + 2 << endl << endl; ... |
#include <bits/stdc++.h> using namespace std; const int N = 100 + 5; double p[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> p[i]; sort(p + 1, p + n + 1); reverse(p + 1, p + n + 1); double one = 0, none = 1; for (int... |
#include <bits/stdc++.h> using namespace std; long a[200001]; long b[200001]; long n; int main() { cin >> n; int k = 1; for (int i = 1; i <= n; i++) { cin >> a[k]; if (a[k] != 0) k++; } k = 1; for (int i = 1; i <= n; i++) { cin >> b[k]; if (b[k] != 0) k++; }... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const int MAX = 1e6 + 5; const long long MOD = 1000000007; struct state { int len, link, cnt; int nx[26]; } st[MAX << 1]; int id, last, cur; vector<int> v[MAX]; inline void sa_init()... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int n; const int MAXN = 2e5; pair<ll, int> arr[MAXN]; ll sum[MAXN]; ll ans = 1e18; void init() { ans = 1e18; } void input() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i].first; } for (int j = 0; j < n; ... |
#include <bits/stdc++.h> using namespace std; char a; int s, kh; int main() { while (cin >> a) { if (a == ( ) s++; else if (s > 0) { kh += 2; s--; } } cout << kh; } |
#include <bits/stdc++.h> using namespace std; bool used[1001]; char c[1001][3][3], z; string s, sr, st; set<char> second; pair<int, string> pr[100001]; vector<long long> v, vc; map<string, int> mp; long long d[1000001]; long long ar[1000001]; long long n, m, b, a, cnt = 1, ans, mn = 99999999999; ... |
#include <bits/stdc++.h> using namespace std; unsigned long long int fibonocci(unsigned long long int n) { unsigned long long int f, f1, f2, i; f1 = 1; f2 = 2; i = 2; while (1) { f = f1 + f2; if (f > n) { return i - 1; } f1 = f2; f2 = f; i++; } }... |
#include <bits/stdc++.h> using namespace std; inline int read() { register int s = 0, f = 0; register char ch = getchar(); while (!isdigit(ch)) { f |= (ch == - ); ch = getchar(); } while (isdigit(ch)) { s = (s << 1) + (s << 3) + (ch ^ 48); ch = getchar(); } retur... |
#include <bits/stdc++.h> using namespace std; int h[15][15]; int dist[15][15]; double expect[15][15]; unordered_map<int, pair<int, int> > dist2pos; int main() { for (int i = 0; i < 10; i++) for (int j = 0; j < 10; ++j) cin >> h[i][j]; for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long n, sum = 0; cin >> n; string arr; string brr; cin >> arr >> brr; for (int i = 0; i < n; i++) { if (brr[i] == 0 ) { continue; } if (ar... |
#include <bits/stdc++.h> using namespace std; int nums[200]; int arr[200][200]; int counter; int line; int main() { int n; cin >> n; line = 0; counter = 0; int sum = 0; int nums[200]; int arr[200][200]; memset(arr, 0, sizeof arr); memset(nums, 0, sizeof nums); while (... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> A[300005]; long long B[300005]; int main() { long long n; scanf( %lld , &n); for (long long i = 1; i <= n; ++i) { scanf( %lld , &A[i].first); A[i].second = i; } sort(A + 1, A + n + 1); long long val = 1;... |
#include <bits/stdc++.h> using namespace std; int main() { int T, n; cin >> T; while (T--) { cin >> n; long long ans = 0; for (int i = 1; i <= n / 2; i++) { ans += i * 1ll * i; } cout << ans * 8 << n ; } return 0; } |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:10000000000 ) #pragma GCC optimize( O3 ) using namespace std; const int MOD = 1000000007; const int INF = 1000000007LL; const long long INF2 = 1000000007LL * 1000000007LL; const long double EPS = 1e-9; const int SIZE = 3010; mt19937 rng(time(0))... |
#include <bits/stdc++.h> std::string input() { static char buf[1000]; scanf( %s , buf); return std::string(buf); } int main() { int inv[5] = {0, 1, 3, 2, 4}; int n, m; std::cin >> n >> m; static int a[500][1000]; for (int i = 0; i < m; i++) { a[i][i + n] = 1; } for (i... |
#include <bits/stdc++.h> using namespace std; const int inf = 1000000000; const int mod = 1000000007; const int sze = 100005; int main() { long long n; char ch; scanf( %I64d%c , &n, &ch); bool flag = true; long long term; if (((n + 3) % 4) == 0) { term = (n + 3) / 4; } else i... |
#include <bits/stdc++.h> using ll = long long int; using namespace std; int main() { ll t; cin >> t; while (t--) { ll p, q; cin >> p >> q; if (p % q != 0) cout << p << n ; else { ll x = 1; for (ll i = 1; i <= sqrt(q); i++) { if (q % i == 0) {... |
#include <bits/stdc++.h> using namespace std; char a[105][105]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int k = 1; k <= 2; k++) { for (int j = 1... |
// Problem: A. Puzzle From the Future // Contest: Codeforces - Codeforces Round #696 (Div. 2) // URL: https://codeforces.ml/contest/1474/problem/A // Memory Limit: 256 MB // Time Limit: 1000 ms // // Powered by CP Editor (https://cpeditor.org) #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h>... |
#include <bits/stdc++.h> using namespace std; template <typename U, typename V> void Min(U &a, const V &b) { if (a > b) a = b; } template <typename U, typename V> void Max(U &a, const V &b) { if (a < b) a = b; } template <typename U, typename V> void add(U &a, const V &b) { a = (a + b) % 1... |
#include <bits/stdc++.h> using namespace std; const int Q = 100100, rt = 223, inf = 1 << 29; int ans[Q], todo[Q]; pair<int, int> look[Q]; int a[Q], b[Q]; string s; unordered_map<int, unordered_set<int>> post; map<pair<int, int>, int> ans2; unordered_map<int, vector<int>> matches; int f(int x, int xs... |
#include <bits/stdc++.h> using namespace std; const int MAX = 7E5 + 10; const int BASE = 1E6 + 3; int n, p; long long f[MAX]; long long power(int x, int n) { if (n == 0) return 1; long long tmp = power(x, n / 2); tmp = tmp * tmp; if (n % 2) tmp = tmp * x; tmp %= BASE; return tmp; }... |
#include <bits/stdc++.h> using namespace std; long long int diff(long long int x, long long int y) { if (x > y) { return x - y; } else { return y - x; } } int main() { long long int n; cin >> n; long long int arr[n]; for (long long int i = 0; i < n; i++) { cin >> ar... |
#include <bits/stdc++.h> using namespace std; set<unsigned int> black[33], white[33]; unsigned int masks[33]; string parseipB(unsigned int x, int mask) { string s = ; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 8; ++j) { s += to_string(1 & x >> 8 * i + j); } if (i != 3)... |
#include <bits/stdc++.h> using namespace std; const int sz = 1e6 + 9; int n, m, k; long long tr[sz], tr_sum, tr_cnt; long long ret[sz], ret_sum, ret_cnt; int d, first, t, c; vector<pair<pair<int, int>, pair<int, int>>> v; vector<pair<long long, long long>> home; long long home_ans[sz]; long long ans... |
#include <bits/stdc++.h> using namespace std; vector<int> v[2005]; int vi[2005]; void dfs(int cu) { int j, l = v[cu].size(); vi[cu] = 1; for (j = 0; j < l; j++) { if (!vi[v[cu][j]]) dfs(v[cu][j]); } } int main() { int n, m, k, cn = 0, i, j; scanf( %d%d , &n, &m); scanf( %d ... |
#include <bits/stdc++.h> using namespace std; int main() { int x11, x12, x13, x21, x22, x23, x31, x32, x33; cin >> x11 >> x12 >> x13 >> x21 >> x22 >> x23 >> x31 >> x32 >> x33; int sum = (x12 + x13 + x21 + x23 + x31 + x32) / 2; x11 = sum - x12 - x13; x22 = sum - x21 - x23; x33 = sum - x31 - x... |
#include <bits/stdc++.h> using namespace std; int n, q; vector<pair<int, int> > L, R; int whereL[30013], whereR[30013]; long long cost[30013][2]; long long dp[30013]; const long long INF = -3.1e16; inline long long match(int a, int b) { if (a <= 0 || b <= 0 || a > n || b > n) return INF; return ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 5e6 + 10; const int MAX = 1e5 + 10; const double eps = 1e-6; priority_queue<int> q, Q; long long s[MAX]; int main() { long long n, k; cin >> n >> k; int cnt = 0; while (n > 0) { long long b = 1; int a = 0; whi... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16777216 ) using namespace std; int a, b, c, d, i, j, n, m, k; int cnt[6]; map<string, int> q; const int di[] = {0, 1, -1, 2, -2, 3, -3, 4, -4}; const char *name[] = { S , M , L , XL , XXL }; int main() { for (int _n((5) - 1), i(0); i <= _... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7, MAXN = 1e5 + 10; int n, l, r, a[MAXN], b[MAXN]; vector<int> aa, bb; int main() { ios_base::sync_with_stdio(0); cin >> n >> l >> r; for (int i = 1; i <= n; ++i) { cin >> a[i]; if (l <= i && i <= r) aa.push_back(a[i])... |
#include <bits/stdc++.h> using namespace std; int s[1509][1509]; long long int dp[1509][1509]; int main() { int m, n, i, j; cin >> n >> m; for (i = 1; i <= n; i++) for (j = 1; j <= m; j++) scanf( %d , &s[i][j]); for (i = 1; i <= n; i++) for (j = 2; j <= m; j++) s[i][j] += s[i][j - 1]... |
#include <bits/stdc++.h> using namespace std; const int MAX = 200000 + 10; const int ALPHA = 30; const int NUM = 12; int T; char a[MAX]; struct Node { Node *ch[ALPHA], *p; int cc[NUM]; int len; Node() { memset(ch, 0, sizeof ch); p = 0; len = 0; memset(cc, 0, sizeof ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.