func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; long n, s[1 << 10]; vector<long> v[1 << 10]; long spre, slim, found; long trem, tail; int main() { ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> s[i]; for (int j = 0; j < 666; j++) v[i].push_back(0); } ... |
#include <bits/stdc++.h> int main(void) { int a, b, m, n, count = 0; scanf( %d %d , &n, &m); for (a = 0; a <= m; a++) { for (b = 0; b <= n; b++) { if (n - b != a * a) continue; if (m - a != b * b) continue; count++; break; } } printf( %d n , count); ... |
#include <bits/stdc++.h> inline int pidorand() { return ((rand() & 32767) << 15) | (rand() & 32767); } using namespace std; inline int nxt() { int x; scanf( %d , &x); return x; } using Point = pair<int, int>; int mydiv(int first, int second) { if (first % second == 0) { return first / ... |
#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; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { ios::sync_with_stdio(false); int n; cin >> n;... |
#include <bits/stdc++.h> using namespace std; string s; int n, res, t; int main() { cin >> n >> s; for (int i = 0; i < n; ++i) { if (s[i] == x ) ++t; else t = 0; if (t >= 3) ++res; } cout << res << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<string> v(n); for (auto& i : v) cin >> i; bool state = true; for (int i = n - 2; i >= 0... |
#include <bits/stdc++.h> using namespace std; int main() { char a[26], b[26], c[26], d[26]; scanf( %s , a); scanf( %s , b); int i = 0, m = 0, n = 0, k, q, w, j = 0, flag = 0, t = 0; while (a[i] != 0 ) { if (a[i] == | ) m = i; i++; } q = m; w = i - m - 1; n = i; ... |
#include <iostream> #include <cstdio> #include <cmath> #include <ctime> #include <cstdlib> #include <cassert> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <string> #include <algorithm> #inclu... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, k, ans = 0, fa = 0, c = 0; cin >> n >> k; c = (n * (n + 1)) / 2; c -= k; c -= n; while (c > 0) { fa++; c -= n; n--; } cout << fa... |
#include <bits/stdc++.h> using namespace std; int n, a, b; int x[105], y[105]; int ans; bool judge(int x1, int x2, int y1, int y2) { if (x1 + x2 <= a && max(y1, y2) <= b) { return 1; } if (x1 + x2 <= b && max(y1, y2) <= a) { return 1; } if (x1 + y2 <= a && max(y1, x2) <= b) { ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { char i = getchar(); long long f = 1, res = 0; while (i < 0 || i > 9 ) { if (i == - ) f = -1; i = getchar(); } while (i >= 0 && i <= 9 ) { res = res * 10 + i - 0 ; i = getchar(); } retu... |
#include <bits/stdc++.h> using namespace std; template <typename T> bool chkmin(T &first, T second) { return second < first ? first = second, 1 : 0; } template <typename T> bool chkmax(T &first, T second) { return first < second ? first = second, 1 : 0; } template <typename T> void readint(T &... |
#include <bits/stdc++.h> using namespace std; int n, head[100000 + 5], sz[100000 + 5], cnt = 1; double ans[100000 + 5]; struct edges { int to, next; } e[2 * 100000 + 5]; inline void insert(int x) { int u = x, v; scanf( %d , &v); e[++cnt] = (edges){u, head[v]}; head[v] = cnt; e[++cnt]... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, c, b; long ans = 0; cin >> n >> m; long a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 0; i < m; i++) { cin >> c >> b; ans += min(a[c], a[b]); } cout << ans; } |
#include <bits/stdc++.h> using namespace std; struct segment { int l, r, fu; bool operator<(const segment &temp) const { return l < temp.l; } }; segment sg[5000]; int cnt_sg; const int inf = 1e9; int xx[400], yy[400]; int cnt_x, cnt_y; struct rectangle { int lx, ly, rx, ry; }; rectangl... |
#include <bits/stdc++.h> using namespace std; int main() { double num, a, b, c, d, e, f, r1, r2; double m1, m2, m3; while (cin >> a >> b >> c >> d >> e >> f) { if (d == 0) { cout << Hermione << endl; continue; } if (c == 0) { cout << Ron << endl; con... |
#include <bits/stdc++.h> int dp[5001][5001]; char s[5001]; int main() { scanf( %s , s); int n; scanf( %d , &n); for (int i = 0; *(s + i); i++) { dp[i][i] = 1; for (int j1 = i - 1, j2 = i + 1; j1 >= 0 && *(s + j2); j1--, j2++) if (s[j1] == s[j2]) dp[j1][j2] = 1; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<ll, ll>; using vi = vector<ll>; using vii = vector<ii>; double x; int main() { cin >> x; for (double a = 1; a <= 10; a++) { for (double h = 1; h <= 10; h++) { double cr = -h * a / 2; double r ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d , &n); scanf( %d , &m); int f[n], b[m], a[m]; map<int, int> x; for (int i = 0; i < n; i++) { scanf( %d , &f[i]); if (x.find(f[i]) != x.end()) x[f[i]] = -1; else x[f[i]] = i; }... |
#include <bits/stdc++.h> using namespace std; const int MXN = 1e5 + 20; int n, a[MXN], b[MXN], c[MXN]; vector<int> ans; void IN() { int tmp; cin >> n; for (int i = 0; i < n; i++) { cin >> tmp; a[i] = tmp; } for (int i = 0; i < n - 1; i++) { cin >> tmp; b[i] = tmp; ... |
#include <bits/stdc++.h> using namespace std; using matrix = vector<vector<long long>>; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int x, l, n, q; cin >> x >> l >> n >> q; int log_n = 0; while ((1 << log_n) <= n) { ++log_n; } vector<int> c(l + 1); fo... |
#include <bits/stdc++.h> double eps = 1e-6; using namespace std; int main() { ios_base::sync_with_stdio(false); int n; long long p, a[100010], b[100010]; long long sum = 0; cin >> n >> p; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; sum += a[i]; } if (p >= sum) { ... |
#include <bits/stdc++.h> using namespace std; long long n, m, f[1050000], a[1050000], b[1050000], mp[21][100005], ans; void fwt(long long a[], long long n, long long f) { for (long long i = 1; i < 1 << n; i <<= 1) { for (long long t = 0; t < 1 << n; t++) { if (i & t) { long long x = a[... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n, sum = 0; while (cin >> n) { for (int i = 0; i < (n); ++i) { int x; cin >> x; sum += x; } if (sum % n) cout << n - 1 << n ; else ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int i, t, n; cin >> t; while (t--) { cin >> n; long long arr[n]; for (i = 0; i < n; i++) { cin >> arr[i]; } reverse(arr, arr + n); for (i = 0; i < n - 1; i++) { cout << arr[i] << ;... |
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; long long int mxm = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n], i; set<long long ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, d; while (cin >> n >> d) { int A[n], ans = 0; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 1; i < n; i++) { if (A[i] <= A[i - 1]) { int rest = A[i - 1] - A[i], cnt = (rest / d) + 1; A[i] ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9; const long long INF = (long long)5e18; const int MOD = 998244353; int add(int x, int y) { x += y; return x >= MOD ? x - MOD : x; } int sub(int x, int y) { x -= y; return x < 0 ? x + MOD : x; } int qpow(int x, int y... |
#include <bits/stdc++.h> using namespace std; int main() { int k, a, b; cin >> k >> a >> b; if (a / k + b / k && a % k <= (b / k) * (k - 1) && b % k <= (a / k) * (k - 1)) cout << a / k + b / k << n ; else cout << -1 n ; return 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 fpow(long long b, long long p) { if (b == 0) return 0; long long ans = 1; while (p) { if (p & 1) ans = ans * b % (998244353); b = b * b % (998244353); ... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long f = 1, sum = 0; char c = getchar(); while (!isdigit(c)) { if (c == - ) f = -1; c = getchar(); } while (isdigit(c)) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum * f; } ... |
#include <bits/stdc++.h> using namespace std; const int N = 210000; vector<int> p[N]; bool vis[N], inq[N]; int fa[N], froot[N], troot[N], size[N], q[N], powk[N], val[N], in0[N], out0[N], in1[N], out1[N], n, jsb, goal, k, dep[N], inv[N]; inline int Pow(int a, int b) { int c = 1; for (; b; b >>=... |
#include <bits/stdc++.h> using namespace std; const int N = 100005; int dp[N]; int pdp[2 * N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int c, n; cin >> c >> n; ++n; pair<pair<int, int>, int> a[n]; a[0] = {{1, 1}, 0}; for (int i = 1; i < n; i++) ci... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e9 + 7; const int N = 3e5 + 10; int a[N]; int b[N]; long long solve(long long x, int n) { long long tmp = 0; for (int i = 1; i <= n; i++) { tmp += a[i] * x / b[i]; } return tmp + n; } int main() { int n, c; ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline T read(register T& t) { register T f = 1; register char ch = getchar(); t = 0; while (ch < 0 || ch > 9 ) { if (ch == - ) f = -f; ch = getchar(); } while (ch >= 0 && ch <= 9 ) t = t * 10 + ch - 0 ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; std::vector<int> v; for (int i = 0; i < n / 2; i++) { v.push_back(2); } if (n % 2 != 0) { v.pop_back(); v.push_back(3); } cout << v.size() << endl; for (auto a : v) cout << a << ; ... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> inline void Max(T &a, U b) { if (a < b) a = b; } template <class T, class U> inline void Min(T &a, U b) { if (a > b) a = b; } inline void add(int &a, int b) { a += b; while (a >= 1000000007) a -= 1000000007; } ... |
#include <bits/stdc++.h> using namespace std; vector<int> vi[200200]; int dp[200200]; int dfs(int now, int prev) { dp[now] = 1; for (auto x : vi[now]) { if (x == prev) continue; dp[now] += dfs(x, now); } return dp[now]; } long long int rose = 0; int n; void rec(int now, int p... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; int n, k, ans = 0, flag = -1, p = 0, sum = 0; cin >> n >> k; long long a[n], i, b[n]; map<long long, long long> m; for (i = 0; i < n; i++) { cin >> ... |
#include <bits/stdc++.h> using namespace std; long long n, d, m; long long lin; long long a[100007], b[100007], la, lb; long long pa[100007], pb[100007]; long long ans; void go(long long l, long long r, long long k) { if (l > r) return; long long mid = (l + r) / 2; long long yu = min(n - ((mid... |
#include <bits/stdc++.h> using namespace std; map<long long int, long long int> m; map<long long int, long long int> m1, m2; int main() { ios_base::sync_with_stdio(0); ; long long int n, k; cin >> n >> k; long long int ans = 0; for (long long int i = 0; i < n; i++) { long long int ... |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple #define ff first #define ss second #define pii pair <int,int> #define pll pair <ll,ll> #define testcase() int t; cin>>t; while(t--) #define forn(i,n) for(int i=0;i<n;i... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007ll; const int INTMAX = numeric_limits<int>::max(); const long long LLMAX = numeric_limits<long long>::max(); void writeln() { cout << n ; } template <class T> inline void print(T&& a); template <class T> inline void priws(... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, t, min = -1, flag = 0; cin >> n; string s; cin >> s; long long int a[n]; for (int i = 0; i < n; i++) { cin >> t; a[i] = t; } for (int i = 1... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int C = 26; void add(int &x, int y) { x += y; while (x >= MOD) x -= MOD; while (x < 0) x += MOD; } int fix(int x) { while (x >= MOD) x -= MOD; while (x < 0) x += MOD; return x; } int pw(int a, int b) { ... |
#include <bits/stdc++.h> using namespace std; using LL = long long; const int SZ = 2000 + 10; LL g_n, g_k, g_p; LL a[SZ], b[SZ]; void prete() {} void input() { for (int i = 0; i < g_n; ++i) { scanf( %I64d , a + i); } for (int i = 0; i < g_k; ++i) { scanf( %I64d , b + i); } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map<string, int> mapp; int mina = 10000000, minb = 10000000, minc = 10000000, minab = 10000000, minac = 10000000, minbc = 10000000, min3 = 10000000; int x; string na; for (int i = 0; i < n; i++) { c... |
#include <bits/stdc++.h> bool visited[200010] = {0}; int first[200010], second[200010], thrid[200010], count = 0; std::set<long long int> happened; long long int f(int one, int two) { return (1LL * 1e6 * std::min(one, two) + std::max(one, two)); } int dfs(int current, std::vector<std::vector<int> > &g, ... |
#include <bits/stdc++.h> using namespace std; vector<int> s; vector<pair<int, int> > v; vector<vector<int> > g; vector<bool> used; map<int, int> mp; int c[1005]; int cl[1005]; int cr[1005]; int main() { ios_base::sync_with_stdio(0); int n, m, k; cin >> n >> m >> k; g.resize(n); f... |
#include <bits/stdc++.h> int gcd(int a, int b, int &counter) { if (b == 0) return a; counter += a / b; return gcd(b, a % b, counter); } int main() { int n; int minn = 1000000; scanf( %d , &n); for (int i = 1; i < n; i++) { int tempCounter = 0; if (gcd(n, i, tempCounter) == ... |
#include <bits/stdc++.h> template <typename T> inline void read(T &x) { x = 0; char c = getchar(); bool flag = false; while (!isdigit(c)) { if (c == - ) flag = true; c = getchar(); } while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); if (flag) x = -x; } using names... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, inf = 15e8; int A[maxn], B[maxn], C[maxn], ANSA, ANSB, n, l, r; vector<int> ed; vector<pair<int, int> > v[maxn]; int SZ[maxn], MX; bool mark[maxn]; pair<int, int> val[2 * maxn]; void dfsS(int u, int par = -1) { SZ[u] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000007; int main() { int a, b; cin >> a >> b; long long S = 0; for (int e = 1; e < b; e++) { long long s1 = ((long long)a * (a + 1) / 2) % INF; long long s2 = (s1 * b) % INF; s2 = (s2 + a) % INF; S = (S + ((s... |
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int a[n]; int mini; int c=0; for(int i=0;i<n;i++){ cin>>a[i]; } // for(int i=0;i<n;i++){ // ... |
#include <bits/stdc++.h> using namespace std; #define int long long bool local=false; int z1; int n; vector <int> a; mt19937 rnd; int med(int x,int y,int z) { vector <int> h={x,y,z}; sort(h.begin(),h.end()); return h[1]; } int query(int u,int v,int w) { cout<< ? <<u+1... |
#include <bits/stdc++.h> using namespace std; const int max_n = 20222, mod = 998244353; int n, k, q, A[max_n], a[max_n]; int dp[max_n]; int solve() { int q1 = 0, q2 = 1; memset(dp, 0, sizeof(dp)); dp[0] = 1; for (int i = 0; i < n; ++i) { for (int j = min(i + 1, k); j >= max(1, k - (n - i... |
#include <bits/stdc++.h> using namespace std; struct TP {}; int ar[5][5]; int ans = 0; int nums[5]; bool used[10]; void cal(int pos) { if (pos == 5) { int tmp = 0; for (int x = 0; x < 5; x++) { for (int y = x; y < 4; y += 2) { tmp += ar[nums[y]][nums[y + 1]]; tm... |
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int x1, y1, x2, y2, res = 0; scanf( %d%d%d%d , &x1, &y1, &x2, &y2); int n; scanf( %d , &n); for (int i = 0; i < (int)(n); ++i) { long long a, b, c; scanf( %lld%lld%lld , &a, &b, &c); long lon... |
#include <bits/stdc++.h> using namespace std; int rup(int x) { if ((x % 7) == 0) { return x / 7; } return (x / 7) + 1; } int main() { int n; cin >> n; for (int i = 0; i < n; i += 1) { int x; cin >> x; cout << rup(x) << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; int a[n], sum = 0; for (int i = 0; i < n; i++) cin >> a[i], sum += a[i]; if (sum + 10 * (n - 1) <= d) cout << (d - sum) / 5; else cout << -1; } |
#include <bits/stdc++.h> using namespace std; const long long INF = 1 << 28; const long long LINF = 1ll << 61; inline long long getnum() { register long long r = 0; register bool ng = 0; register char c; c = getchar(); while (c != - && (c < 0 || c > 9 )) c = getchar(); if (c == - )... |
#include <bits/stdc++.h> const double pi = 3.1415926535; using namespace std; int main() { double n, r; cin >> n >> r; r = sin(pi / n) * r / (1 - sin(pi / n)); cout << fixed << setprecision(7) << r; return 0; } |
#include <bits/stdc++.h> using namespace std; class SegmentTree { private: int n; vector<int> st; int left(int p) { return (p << 1); } int right(int p) { return (p << 1) + 1; } int parent(int p) { return (p >> 1); } void build(int p, int L, int R) { if (L == R) st[p] = A[L];... |
#include <bits/stdc++.h> using namespace std; int u = 1, i = 0, q1, q2, a[100001], s[200002], d[100000], f[100001]; void k(int w) { q2 = w / 2; while (a[s[q2]] > a[q1]) { s[w] = s[q2]; w = q2; q2 /= 2; } s[w] = q1; } void l() { if (i) { i--; k(d[i]); } els... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; long long res = 0; cin >> n >> m; int v[n]; for (int i = 0; i < n; i++) { cin >> v[i]; } for (int i = 0; i < m; i++) { int x, y; cin >> x >> y; res += min(v[x - 1], v[y - 1]); } cout << r... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n), b(n); pair<int, int> p; vector<pair<int, int> > v; for (int i = 0; i < n; i++) { cin >> a[i]; } iota(b.begin(), b.end(), 0); sort(b.begin(), b.end(), [&](int x, int y) { if... |
#include bits/stdc++.h using namespace std; #define ll long long #define Rip_classic_loki_for_glorious_purpose ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #pragma GCC target ( avx2 ) #pragma GCC optimization ( O3 ) #pragma GCC optimization ( unroll-loops ) // need for speed ... |
#include <bits/stdc++.h> using namespace std; bool compare(vector<long long> &A, vector<long long> &B) { if (A[0] - A[1] > B[0] - B[1]) return true; return false; } int main() { long long(n), (a), (b); scanf( %lld%lld%lld , &(n), &(a), &(b)); ; vector<vector<long long>> A, B; long lo... |
#include <bits/stdc++.h> using std::list; const int N = 128; struct car { int coord, length, req; }; list<car> cars; int InsertCar(int length, int req, int b, int f) { list<car>::iterator i = cars.begin(), j = ++cars.begin(); int from, to; while (j != cars.end()) { from = i->coord + i-... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; const int INF = 0x3f3f3f3f; const long long mod = 1e9 + 7; int n, k; int a[MAXN]; stack<pair<int, int> > s; int l[MAXN], r[MAXN]; long long cal(int l, int r) { if (l > r || r - l + 1 - k < 0) return 0; int m = (r - l + 1 -... |
#include <bits/stdc++.h> using namespace std; const int N = 200000 + 10; int n; long long x[N], y[N]; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { scanf( %lld%lld , &x[i], &y[i]); } while (1) { vector<int> r; for (int i = 1; i <= n; i++) { if ((x[i] + ... |
#include <bits/stdc++.h> using namespace std; long long inf = 2147483647; const long long ll = 9223372036854775807, ninf = 1000000000; const double eps = 1e-6; const long long nll = 1000000000000000000; class CircleOrder { public: string firstOrder(string s) {} }; long long C[1005][1005] = {}; ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; inline int add(int a, int b); inline int mult(int a, int b); inline int sub(int a, int b); inline int divv(int a, int b); int p1[300500]; int p2[300500]; int pow1 = 37; int pow2 = 41; int mod1 = 1000000007; int mod2 = 1000... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 3e3 + 4; long long dp[N]; int main() { int n; scanf( %d , &n); vector<pair<int, int>> v(n); for (int i = 0; i < n; i++) scanf( %d , &v[i].first), scanf( %d , &v[i].second); sort(v.begin(), v.end()); ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n; cin >> n; long long a[n]; for (long long i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (a[n - 1] >= a[n - 2] + a[n - 3]) { cout <... |
#include <bits/stdc++.h> using namespace std; int main() { long long int k, d, t; cin >> k >> d >> t; long long int k1, k2; k1 = k; k2 = (k / d) * d + (int)(k % d != 0) * d - k; t *= 2; long long int bal = 2 * k1 + k2; long long int n = t / bal; double time = n * (k1 + k2); d... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, d; cin >> a >> b >> d; if (d < a) cout << d << endl; else { cout << b + d - (b % d) << endl; } } } |
#include <bits/stdc++.h> using namespace std; int x1, yy1, r1, R1; int x2, y2, r2, R2; int dis; inline bool inside(int r, int R) { double dist = sqrt((double)dis); if (dist <= double(R - r)) return true; return false; } inline bool outside(int r, int R) { double dist = sqrt((double)dis); ... |
#include <bits/stdc++.h> using namespace std; int T, n, cnta[4], cntb[4], dy[2][2], ans[4040], k; char a[4040], b[4040]; int main() { dy[0][0] = 0, dy[0][1] = 1, dy[1][0] = 2, dy[1][1] = 3; scanf( %d , &T); while (T--) { scanf( %s %s , a + 1, b + 1); n = strlen(a + 1); k = 0; ... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); vector<int> v; int main() { ios_base::sync_with_stdio(0); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, x; bool tt = 0; cin >> n; for (int i = 0; i < n; ++i) { cin >> x; v.push_... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6; const int inf = 1e6; int n, m; int a[maxn + 5], b[maxn + 5]; int tag[maxn << 2], mx[maxn << 2]; void seta(int p, int d) { tag[p] += d; mx[p] += d; } void push(int p) { seta(p + p, tag[p]); seta(p + p + 1, tag[p]); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100 + 5; struct node { long long x, y; int id; bool operator<(const node &ope) const { return y < ope.y; } } a[maxn]; bool vis[maxn][maxn]; long long dp[maxn][maxn]; bool vis2[maxn]; inline void init() { memset(dp, -1, sizeof... |
#include <bits/stdc++.h> using namespace std; int t, n, m, a[105], S; int main() { cin >> t; while (t--) { cin >> n >> m; S = 0; for (int i = 1; i <= n; ++i) { cin >> a[i]; S = S + a[i]; } if (S == m) cout << YES ; else cout << NO ; ... |
#include <bits/stdc++.h> using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; struct line { int sx, sy, ex, ey; friend bool operator<(const line &A, const line &B) { return A.sx < B.sx; } }; map<char, line> mp; int n, m; char s[2005][2005], p[2005][2005], mxx; void init() { for (char x = a ; x <=... |
#include <bits/stdc++.h> using namespace std; struct disjoint_set { vector<int> p; disjoint_set(int n) : p(n, -1) {} bool share(int a, int b) { return root(a) == root(b); } int sz(int u) { return -p[root(u)]; } int root(int u) { return p[u] < 0 ? u : p[u] = root(p[u]); } bool merge(int u, in... |
#include <bits/stdc++.h> using namespace std; char s[1001][7]; int n, a[30], p, m, ch, j, mn, mx, val, o; long long sum; struct chestie { int c, fr, ok, nr; } v[30]; int pow(int N, int E); bool comp(chestie X, chestie Y); int main() { cin >> n; for (int i = 1; i <= n; i++) { cin.get(... |
#include <bits/stdc++.h> using namespace std; long long read() { long long f = 1, x = 0; char s = getchar(); while (s < 0 || s > 9 ) { if (s == - ) f = -f; s = getchar(); } while (s >= 0 && s <= 9 ) { x = x * 10 + (s - 0 ); s = getchar(); } return f * x; ... |
#include <bits/stdc++.h> using namespace std; int N; long long gMin = 1e12, gMax = -1e12, rMin = 1e12, rMax = -1e12, bMin = 1e12, bMax = -1e12, lasty = -1e12, ret = 0; vector<long long> notGreen[2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(18... |
#include <bits/stdc++.h> using namespace std; struct node { int x, y; }; int n, m, d[5005]; node a[5005]; bool cmp(const node &x, const node &y) { return x.x == y.x ? x.y < y.y : x.x < y.x; } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %d%d , &a[i].x, &a[i].y); ... |
#include <bits/stdc++.h> using namespace std; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __prin... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-9; double sqrDist(double x1, double y1, double x2, double y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } double dist(double x1, double y1, double x2, double y2) { return sqrt(sqrDist(x1, y1, x2, y2)); } const double... |
#include <bits/stdc++.h> using namespace std; vector<int> r1, r2; vector<bool> pd; vector<int> out; vector<pair<int, int>> mp; int le(int i, int cur) { if (cur == mp[i].first) return mp[i].second; return mp[i].first; } bool mak(int i, int p) { if (mp[i].first == -1) mp[i].first = p; ... |
#include <bits/stdc++.h> using namespace std; vector<long long> readvec(long long length, long long off = 0); template <typename T> string ts(T v); int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n; long long z; cin >> n >> z; vector<long long> v = readvec(n); sort... |
#include <bits/stdc++.h> using namespace std; int arr[2505][2505], sum[2505][2505], n, m; int get_sum(int x1, int y1, int x2, int y2) { x2 = min(x2, n); y2 = min(y2, m); assert(x1 <= x2); assert(y1 <= y2); return sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1]; } int ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { int n; string s, ss; cin >> s >> n; vector<pair<int, string> > v(n + 1); v[0] = make_pair(0, s); char next; while (cin.get(next)) if (next == n ) break; for (int i = 1; i <= n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = (int)2e5 + 5; int n, a[maxn], vis[2 * maxn], mx[maxn]; long long ans; vector<int> slist[maxn]; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } void doit(int d) { for (int i = 0; i < d; i++) mx[i] = 0; for (int i = 0; i < n; i++... |
#include <bits/stdc++.h> using namespace std; vector<int> G[200005]; bool V[200006] = {0}; int S[200006] = {0}; int n; long long d = 0, mx = 0; void dfs(int p) { V[p] = 1; d++; int u = 0; for (int i = 0; i < G[p].size(); i++) { int cp = G[p][i]; if (!V[cp]) { dfs(cp); ... |
#include <bits/stdc++.h> using namespace std; long long int a[1000000]; struct cr { int l; int r; int d; } op[1000000]; long long int kt[1000000]; long long int ktt[1000000]; long long int fiop[1000000]; long long int vp[1000000]; long long int vpp[1000000]; long long int mba[1000000]; ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using db = double; const int mxn = 100006; int n, m; int a[mxn]; vi e[mxn]; bool v[mxn]; vi V; void dfsv(int x, int p) { v[x] = true; V.push_back(x); for (auto i : e[x]) if (i != p && !v[i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.