func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int N, M; const int MAX = 1e6; vector<int> edges[MAX]; int indeg[MAX]; vector<int> source; map<int, int> sink; int reachable[20]; const int BITMAX = 1 << 20; int dp[BITMAX]; void dfs(int start, int i) { if (sink.count(i)) { reachable[start] |... |
#include <bits/stdc++.h> const long long _INF = 1e18; const int INF = 1e9; using namespace std; int T; void solved() { long long n = 0; cin >> n; if (n % 2 == 1) n++; if (n <= 6) cout << 15 << n ; else cout << n * 5 / 2 << n ; } int main() { setbuf(stdout, NULL); ... |
#include <bits/stdc++.h> using namespace std; int main() { int i = 0, a = 0, b = 0; string s; cin >> s; while (s[i] != 0 ) { if (s[i] >= 65 && s[i] <= 90) { a++; } else if (s[i] >= 97 && s[i] <= 122) b++; i++; } i = 0; if (a > b) { while (s[i] !=... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 20; int n, x, i, f[N]; int main() { scanf( %d , &n); while (n--) scanf( %d , &x), f[x]++; for (i = N - 1; i >= 0; i--) if (f[i] & 1) return 0 * printf( Conan ); printf( Agasa ); } |
#include <bits/stdc++.h> using namespace std; const int mod = 51123987; int f[160][53][53][53]; int n, m, ans, a[160][3]; char s[160]; void up(int &a, int b) { a += b; a %= mod; } int main() { scanf( %d n%s , &n, s); a[n][0] = a[n][1] = a[n][2] = n; for (int i = n - 1; i >= 0; i--) {... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1e3 + 7; int n, m, k; int x[N], y[N]; vector<int> s[N], t[N]; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; int bor[4]; int xnow, ynow, flg[N]; int main() { scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= k; i++) { s... |
#include <bits/stdc++.h> using namespace std; long long n, i, j, a[4][100001], dp[4][100001]; int main() { cin >> n; for (i = 0; i < 3; i++) for (j = 0; j < n; j++) cin >> a[i][j]; dp[2][n - 1] = a[2][n - 1]; dp[1][n - 1] = dp[2][n - 1] + a[1][n - 1]; dp[0][n - 1] = dp[1][n - 1] + a[0][n... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; while (t--) { long long n, x; cin >> n; string s = ; if (n % 2 == 0) { s += 1 ; } else s += 7 ; ... |
#include <bits/stdc++.h> using namespace std; int arr[250]; int N = 250; void tmain() { double m = 0; for (int i = 0; i < N; ++i) { scanf( %d , arr + i); m += arr[i]; } m /= N; double dev = 0; for (int i = 0; i < N; ++i) { dev += (m - arr[i]) * (m - arr[i]); } d... |
#include <bits/stdc++.h> using namespace std; #define ll long long ll gcd(ll a, ll b){ if (a == 0) return b; if (b == 0) return a; if (a == b) return a; if (a > b) return gcd(a-b, b); return gcd(a, b-a); } int main(){ ll t; cin>>t; ... |
#include <bits/stdc++.h> using namespace std; vector<int> v; void sep(int x) { if (x == 0) return; sep(x / 10); v.push_back(x % 10); } int main() { int i; for (int i = 1; i < 1 << 30 && v.size() < 1010; i++) { sep(i); } int x; cin >> x; cout << v[x - 1]; return 0;... |
#include <bits/stdc++.h> using namespace std; int mod = 998244353; int main() { ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; long long int fac[n + 1]; fac[0] = 1; for (int i = 1; i <= n; i++) { fac[i] = fac[i - 1] * i; fac[i] %= mod; } ... |
#include <bits/stdc++.h> using namespace std; int N, V, k, y; vector<int> vec; int main() { cin >> N >> V; for (int i = 1; i <= N; i++) { cin >> k; int x = 1000000000; for (int j = 1; j <= k; j++) { cin >> y; x = min(x, y); } if (x < V) vec.push_back(i); ... |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9, mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int a, b; cin >> a >> b; int ans = 0; int x = abs(a - b); ans += x / 5; x %= 5; ans += x ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2e9; int fa[100010], n, cnt; bitset<1010> G[1010], S[1010], vis; int find(int x) { if (fa[x] == x) return x; return fa[x] = find(fa[x]); } int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) { int k, x; scanf(... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long a[n], b[n]; for (long long i = 0; i < n; i++) { cin >> a[i] >> b[i]; } long long sum = 0; long long price = 99999; for (long long i = 0; i < n; i++) { price = min(price, b[i]); ... |
#include <bits/stdc++.h> using namespace std; int cmp(double x, double y) { if (fabs(x - y) < 1e-7) return 0; if (x < y) return -1; return 1; } float call(double a, double b) { double s1, s2; if (cmp(a / 4, b) <= 0) { s1 = b + a / 8; } else { double l1, l2, t1, t2; l1 =... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; int BIT[4][11][MAXN * 2], n; void add(int BIT[], int p, int x) { for (int i = p; i <= n; i += ((i) & (-(i)))) BIT[i] += x; } int ask(int BIT[], int p) { int res = 0; for (int i = p; i; i -= ((i) & (-(i)))) res += BIT[i]; ... |
#include <bits/stdc++.h> using namespace std; void printPath(vector<pair<int, int>> &path) { for (auto it : path) cout << (it.first + 1) << << (it.second + 1) << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; long long arr[n][n]; ... |
#include <bits/stdc++.h> using namespace std; string ori; string start; string target; int n; char mapping[256]; char mapn[256]; char used[256]; bool apply(int a, int b) { if ((mapping[a] == 0 && used[b] == false) || mapping[a] == b) { mapping[a] = b; used[b] = true; mapn[a]++; ... |
#include <bits/stdc++.h> using namespace std; vector<int> g1[2111]; vector<int> g2[2111]; vector<int> v1, v2; int s1[1111][1111]; int s2[1111][1111]; int N; pair<int, int> dfs1(int v) { pair<int, int> p = {1000, 0}; if (v1[v]) p = {v1[v], v1[v]}; for (auto to : g1[v]) { auto cur = dfs1... |
#include <bits/stdc++.h> int main() { int s, v1, v2, t1, t2; scanf( %d %d %d %d %d , &s, &v1, &v2, &t1, &t2); int a = s * v1 + 2 * t1; int b = s * v2 + 2 * t2; if (a == b) { printf( Friendship n ); } else if (a < b) { printf( First n ); } else { printf( Second n ); } ... |
#include <bits/stdc++.h> using namespace std; const long long maxn = 5e5 + 10; long long N, arr[maxn], use[maxn]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (register long long i = 1; i <= N; ++i) { cin >> arr[i]; } sort(arr + 1, arr + 1 + N); long l... |
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int ones = 0, zeros = 0; for (char c : s) { if (c == n ) ones++; if (c == r ) zeros++; } while (ones--) cout << 1 ; while (zeros--) cout << 0 ; cout << endl; return 0;... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> T pow_mod(T a, U b, int mod) { T r = 1; for (; b > 0; b >>= 1) { if (b & 1) r = (long long)r * a % mod; a = (long long)a * a % mod; } return r; } enum bit_op { AND, OR, XOR }; namespace bitwise_transf... |
#include <bits/stdc++.h> using namespace std; int n, k, x, y, l, r, fact[200001], inv[200001], mod = 1e9 + 7; map<int, int> m; int powlog(int a, int b) { if (b == 0) return 1; int ret = powlog(a, b / 2); if (b % 2) return 1LL * ret * ret % mod * a % mod; return 1LL * ret * ret % mod; } int C... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> inline T range(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } inline void setin(string s) { freopen(s.c_str(), r , stdin); } inline void setout(string... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = 1e6 + 10, K = 2e4 + 10; int head[N], h2[N], cur[N], dep[N], to[M], lim[M], nxt[M], vis[N], cnt = 1, n, m, s, t; void add_edge(int u, int v, int l, int *head) { nxt[+... |
#include <bits/stdc++.h> using namespace std; double PI = 3.14159265358979323846; int rx[8] = {1, 1, 1, -1, -1, -1, 0, 0}; int ry[8] = {0, -1, 1, 0, -1, 1, 1, -1}; int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int n, k, a, b, c, d, h; bool u[1111]; int main() { ios_base::sync... |
#include <bits/stdc++.h> using namespace std; long long in() { int32_t x; scanf( %d , &x); return x; } inline long long lin() { long long x; scanf( %lld , &x); return x; } inline void read(long long *a, long long n) { for (long long i = 0; i < n; i++) a[i] = in(); } inline vo... |
#include <bits/stdc++.h> using namespace std; const int N = 300000 + 10; const long long MOD = 1000000000 + 7; const long long INF = 10000000; vector<long long> Poi; unordered_map<long long, long long> koj; long long q, SEG[4 * N][2], lazy[4 * N]; vector<pair<int, pair<long long, long long>>> Q; void ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const int max0 = 1e7; const int maxm = 400; const int maxabs = 101; const int max1 = 1e3; bool a[(maxabs << 1) + 5][(maxabs << 1) + 5] = {{0}}; int pre[(max1 << 1) + 5][(max1 << 1) + 5] = {{0}}; int n, ax, ay, bx, by; int walk[... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); size_t n, m, q; cin >> n >> m >> q; vector<uint32_t> perm(n); for (size_t i = 0; i < n; ++i) { cin >> perm[i]; perm[i]--; } vector<uint32_t> a(m); for (size_t i = 0; i < m; ++i) {... |
#include <bits/stdc++.h> using namespace std; int rel[50][50], tk[50], vis[50]; int x[20][3], p, alone[50]; int dfs(int i, int r, int n) { vis[i] = r; int j, k = 1; for (j = 1; j <= n; j++) { if (rel[i][j] && vis[j] == 0) { k += dfs(j, r, n); } } return k; } int main(... |
#include <bits/stdc++.h> using namespace std; int main() { int q; scanf( %d , &q); while (q--) { int n; scanf( %d , &n); vector<int> a(n); for (int i = 0; i < n; i++) scanf( %d , &a[i]); sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); n =... |
#include <bits/stdc++.h> using namespace std; const int N = 500010; int n, a[N], rt = 1, ba[30], sta[N], top = 0; vector<int> e[N]; long long ans; void dfs(int u, int ff) { sta[++top] = u; if (ff) { long long w = a[sta[top - 1]]; int i = 1; for (; top - ba[i] > 0; i++) if (... |
#include <bits/stdc++.h> int main() { int x1, y1, r1, x2, y2, r2; scanf( %d %d %d %d %d %d , &x1, &y1, &r1, &x2, &y2, &r2); double ans; ans = (sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) - r1 - r2) / 2; if (ans < 0) if (r1 > r2) ans = (r1 - r2 - sqrt((x2 - x1) * (x2 - x1) + (... |
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; long long quickpow(long long a, long long b) { long long ans = 1; a = a % mod; while (b > 0) { if (b % 2) ans = ans * a; b = b / 2; a = a * a; } return ans; } int gcd(int a, int b) { return b... |
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <queue> #include <deque> #include <bitset> #include <iterator> #include <list> #include <stack> #include <map> #include <set> #include <functional> #include <numeric> #include <utility>... |
#include <bits/stdc++.h> using namespace std; vector<int> odd; int main() { int n, t; cin >> n; long long cnt = 0, res = -1e9; for (int i = 0; i < n; i++) { cin >> t; if (abs(t) % 2 == 1) odd.push_back(t); else if (t > 0) cnt += t; } sort(odd.begin(), odd.... |
#include <bits/stdc++.h> using namespace std; int main() { long double n, k; cin >> n >> k; string s; cin >> s; set<string, greater<string> > st; queue<string> stk; stk.push(s); while (k && !stk.empty()) { string temp = stk.front(); stk.pop(); if (st.find(temp) == s... |
#include <bits/stdc++.h> int n, m; int a[200010], b[200010], fail[200010]; int main() { scanf( %d %d , &m, &n); --n; --m; int x, y; scanf( %d , &x); for (int i = 0; i < m; ++i) { scanf( %d , &y); b[i] = y - x; x = y; } scanf( %d , &x); for (int i = 0; i < n; +... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; int dp[N], c[N]; long long ncr[N][N]; void pascal() { ncr[0][0] = 1; for (int i = 1; i < N; i++) { ncr[i][0] = 1; for (int j = 1; j <= i; j++) { ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % 1000000007; } ... |
#include <bits/stdc++.h> using namespace std; int MSB1(long long x) { int d = 0; while ((1LL << d) <= x) d++; return d; } int main() { int n, m; cin >> n >> m; struct Elm { int l, r, x; }; vector<vector<Elm>> vals(n); while (m--) { int op; cin >> op; i... |
#include <bits/stdc++.h> using namespace std; bool isprime(int n) { for (int i = (2); i < (sqrt(n) + 1); ++i) if (n % i == 0) return false; return true; } int main() { vector<int> ans; int h[400] = {0}; for (int i = 4; i < 400; i += 2) h[i] = 1; h[2] = 0; h[1] = 1; for (int... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<long double, long double> > v(n); int k = 0; for (int i = 0; i < n; ++i) { long double a, b, c; cin >> a >> b >> c; if (c == 0) ++k; long d... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const int N = 52; int n, T; int t[N], x[N], c[5]; long long f[2][N][N][N * N + 50]; long long g[2][N][N * N]; long long cnt[N][N][N]; long long dp[N][N][N][4], fac[N]; int main() { fac[0] = 1; for (int i = 1; i < N;... |
#include <bits/stdc++.h> using namespace std; vector<long long unsigned> p_pow; vector<long long unsigned> reverse_p_pow; const int hash_base = 31; long long unsigned binpow(long long unsigned a, long long unsigned n) { long long res = 1; while (n) { if (n & 1) res *= a; a *= a; n >>... |
#include <bits/stdc++.h> using namespace std; const int s = 1e6; int vis[s]; int main() { int n, t; scanf( %d , &n); for (int i = 0; i < n; i++) { scanf( %d , &t); vis[t] = 1; } printf( %d n , n); int num = 0; for (int i = 0; i < s + 2; i++) { if (vis[i] == 1) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0, cnt2 = 0; cin >> n; int w; for (int i = 0; i < n; i++) { cin >> w; if (w == 100) cnt++; if (w == 200) cnt2++; } if (cnt == 0 && cnt2 % 2 != 0) { cout << NO ; return 0; } if (cnt ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn = 1e6 + 6; int a[maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int pt = 0; if (n & 1) { for (int i = 2; i <= n; i += 2) { a[pt++] = i; } ... |
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); } struct Frac { long long a, b; Frac(long long aa = 0, long long bb = 1) { if (bb < 0) { aa = -aa; bb =... |
#include <bits/stdc++.h> using namespace std; inline int ni() { int a; scanf( %d , &a); return a; } inline double nf() { double a; scanf( %lf , &a); return a; } template <class T> void out(T a, T b) { bool first = true; for (T i = a; i != b; i++) { if (!first) printf(... |
#include <bits/stdc++.h> const int INF_INT = 0x3f3f3f3f; const long long INF_LL = 0x7f7f7f7f; const int MOD = 1e9 + 7; const double eps = 1e-10; const double pi = acos(-1); using namespace std; int n; int a[30]; int vis[30]; bool dfs(int root, int cnt, int son) { if (root == n + 1) return true; ... |
#include <bits/stdc++.h> using namespace std; long long int arrx[100]; long long int arry[100]; long long int arr[10000]; map<long long int, bool> M; void parr(long long int a[], long long int n); int main() { long long int x, y, l, r, ss, siz, sizx, sizy, mulx, muly, start, ans, fin, ran, tem... |
#include <bits/stdc++.h> using namespace std; vector<int> adj[300010]; bool vst[300010]; int dp[300010][2]; int root[300010]; int cnt[300010]; int dst[300010]; int find_root(int u) { if (root[u] == u) return u; return root[u] = find_root(root[u]); } void reunion(int u, int v) { u = find_... |
#include <bits/stdc++.h> using namespace std; double a, d; double pre(double v) { if (d >= (v * v) / (2.0 * a)) { double x = v / a; double y = d - ((v * v) / (2.0 * a)); double out = x + (y / (v)); return out; } else { double out = sqrt((2.0 * d) / a); return out; }... |
#include <bits/stdc++.h> using namespace std; bool sushu(long long n) { long long t = sqrt(n); for (long long i = 2; i <= t; i++) { if (n % i == 0) return false; } return true; } long long ret(long long n) { long long ne = 0; while (n != 0) { ne = ne * 10 + n % 10; n = ... |
#include <bits/stdc++.h> using namespace std; void ckmx(int &x, int y) { x = max(x, y); } const int N = 100050; const int L = 17; const int M = 2 * N; int root, ls[M], rs[M], tsz, mx[M], lzy[M]; void Build(int &c, int ss, int se, int a[]) { c = ++tsz; lzy[c] = 0; if (ss == se) { mx[c] = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5, maxk = (1 << 20), inf = 1e9; int dp[maxk][2]; int ind[20]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; string a, b; cin >> a >> b; int c = 0, d =... |
#include <bits/stdc++.h> using namespace std; int h, t; vector<vector<int> > graph; vector<int> lvl; int edges[100005][2]; int stat[100005]; int check(int u, int v) { int len = h + t; int ht = 0; int tt = 0; stat[u] = -1; stat[v] = -1; int i = 0; while (ht < len) { int a ... |
#include <bits/stdc++.h> using namespace std; vector<int> adj[3010]; pair<int, long long> dp[3010][3010], tmp[3010]; int v[3010], sz[3010]; void merge(int x, int y) { for (int i = 0; i < sz[x] + sz[y]; i++) tmp[i] = pair<int, long long>(-1, 0); for (int i = 0; i < sz[x]; i++) for (int j = 0; j <... |
#include <bits/stdc++.h> using namespace std; int abc; inline int rd(int l, int r) { return rand() % (r - l + 1) + l; } const int mxn = 2e5 + 3, mod = 998244353; long long por(long long x, int y = mod - 2) { long long r = 1; for (; y; y >>= 1) { if (y & 1) r = r * x % mod; x = x * x % mod;... |
#include <bits/stdc++.h> using namespace std; bool DEB = false; void MP() { ios::sync_with_stdio(false); cin.tie(0); } #pragma comment(linker, /STACK:256000000 ) const long long inf = (long long)1e13 + 9; const int MAX = (int)3e5 + 10; int a[MAX]; long long t[4 * MAX][2][2]; inline void f(i... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, x, y; cin >> n >> m; vector<pair<int, int>> v; for (int i = 0; i < m; i++) { cin >> x >> y; v.push_back({y, x}); } sort(v.begin(), v.end()); int ans = 0, counter = 0; for (int i = m - 1; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; int val[300005]; long long num[300005]; int main() { int n; scanf( %d , &n); long long s = 0; for (int i = 1; i <= n; i++) { scanf( %d%lld , &val[i], &num[i]); s += val[i]; } long long ans = 0; for (int i = 61; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; while (n--) { cout << 1 << ; } cout << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { solve(); } return 0; } |
#include <bits/stdc++.h> using std::cin; using std::cout; const int N = 5054, mod = 1000000007; int n, K; int f[N]; long long PowerMod(long long a, int n, long long c = 1) { for (; n; n >>= 1, a = a * a % mod) if (n & 1) c = c * a % mod; return c; } int main() { int i, j, x, in, ans = ... |
#include<bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while(t--){ string s; cin >> s; cout << s.size() << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; int seq[100050]; int n; int l[40], r[40]; int dp[100050]; bool chk() { for (int i = 1; i <= n; ++i) if (seq[i] != i) return false; return true; } void dfs(int dep) { if (chk()) { printf( %d n , dep); for (int i = dep; i >= 1; --... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> Height(n); vector<int> count(n, 0); for (int i = 0; i < n; i++) { cin >> Height[i]; } int x = 0, after = 1, befor = 0; while (after < n && Height[x] >= Height[after]) { count[0]++; ... |
#include <bits/stdc++.h> using namespace std; int read() { char ch = getchar(); int x = 0, fl = 1; for (; !isdigit(ch); ch = getchar()) if (ch == - ) fl = -1; for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch - 0 ); return x * fl; } const int NN = 500000 + 17; const... |
#include <bits/stdc++.h> using namespace std; struct Segment { int x1, y1, x2, y2; }; struct Line { long long a, b, c; }; int n; Segment seg[1005]; map<pair<int, int>, int> intersectCount; unordered_map<int, int> toSubtract; int gcd(int a, int b) { if (b == 0) return a; return gcd(b,... |
#include <bits/stdc++.h> using namespace std; long long C[1007][1007]; int main() { long long n, m, k; memset(C, 0, sizeof(C)); C[0][0] = 1; for (long long i = 1; i <= 1000; i++) { C[i][0] = 1; for (long long j = 1; j <= i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 10000... |
#include <bits/stdc++.h> using namespace std; struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } } _io; using ll = long long; using db = long double; using pi = pair<int, int>; using mi = map<int, int>; const int N = 6e5 + 5, M = 1e9 + 7; using vi = vector<int>; ll ri() ... |
#include <bits/stdc++.h> using namespace std; const long long N = 200010, M = 2000010, INF = 0x3f3f3f3f; inline long long max(long long x, long long y) { return x > y ? x : y; } inline long long min(long long x, long long y) { return x < y ? x : y; } inline void swap(long long &x, long long &y) { x ^= y ^= x ... |
#include <bits/stdc++.h> int inp() { char c = getchar(); int neg = 1; while (c < 0 || c > 9 ) { if (c == - ) neg = -1; c = getchar(); } int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum * neg; } int a[110];... |
#include <bits/stdc++.h> using namespace std; int tot[100100]; int maxd = 0; vector<vector<int> > g; void dfs(int v, int d, int p) { maxd = ((maxd < d) ? (d) : (maxd)); tot[d]++; for (int i = (0); i < (g[v].size()); ++i) { int to = g[v][i]; if (to != p) { dfs(to, d + 1, v); ... |
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long n, e = 0, o = 0; long long i, j; long long ans = 0; string str; cin >> str; for (i = 0; i < str.size(); i++) { if (str[i] == 0 ) e++; e... |
#include <bits/stdc++.h> using namespace std; class B_808 { public: int main() { int n, k, a[200005]; double ans = 0.0, sum = 0.0; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < k; i++) sum += a[i]; ans += sum / ((double)n - k + 1); for (... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const int maxm = 1e5 + 5; const long double eps = 1e-14; const long double eps2 = 1e-9; const long double INF = 1 << 30; inline int dcmp(const long double& x) { return fabs(x) < eps ? 0 : (x < 0 ? -1 : 1); } pair<long double, ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 1) { cout << 0; return 0; } n = n / 2; if (n % 2 == 0) cout << n / 2 - 1; else cout << n / 2; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; const int mod = 1e9 + 7; const long long inf = 1e18; int d, n, m, x[N], p[N], cur, r[N]; long long ans = inf, carry; pair<int, int> a[N]; int main() { ios_base::sync_with_stdio(0); cin >> d >> n >> m; for (int i = 1; i <= m... |
#include <bits/stdc++.h> using namespace std; vector<int> g[1000010]; int n, k; bool r[1000010]; int s[1000010]; int m[1000010]; int main() { scanf( %d %d , &n, &k); for (int i = 0; i < k; i++) { int x, y; scanf( %d %d , &x, &y); g[x].push_back(y); } int v = 0; for (i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 100; int c[maxn], a[maxn]; int main() { int n, m, l = 0, ans = 0; cin >> n >> m; for (int i = 0; i < n; i++) cin >> c[i]; for (int i = 0; i < m; i++) cin >> a[i]; for (int i = 0; i < n; i++) if (a[l] >= c[i]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; string s; cin >> s; int x = 0, y = 0, pos = 0, coin = 0; if (s[0] == R ) x++; else y++; if (y > x) pos = 2; if (x > y) pos = 1; fo... |
#include <bits/stdc++.h> using namespace std; int main() { long long int r, x, y, x1, y1; cin >> r >> x >> y >> x1 >> y1; double d; d = pow((((x - x1) * (x - x1)) + ((y - y1) * (y - y1))), 0.5); cout << ceil(d / (2 * r)) << endl; } |
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, min1, min2, a, b; cin >> t; while (t--) { cin >> n; long long arr1[n]; long long arr2[n]; for (long long c = 0; c < n; c++) { cin >> arr1[c]; } for (long long d = 0; d < n; d++) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int a[maxn]; long long s[maxn], ss[maxn]; pair<int, long long> que[maxn]; int tot; pair<int, long long> operator-(pair<int, long long> b, pair<int, long long> a) { pair<int, long long> c; c.first = b.first - a.first; c.seco... |
#include <bits/stdc++.h> using namespace std; int row[] = {0, 1, 0, -1, -1, -1, 1, 1}; int col[] = {1, 0, -1, 0, 1, -1, -1, 1}; const long long N = 2e5 + 10; const long long M = 1e18 + 7; const long long H = 1e9 + 7; const long long base = 131; long long logx(long long a, long long bs) { return log(a) /... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 11; const long long MOD0 = 1e9 + 7; const long long P0 = 37; const long long MOD1 = 1e9 + 9; const long long P1 = 49; long long a[N], b[N]; long long h1[2][N], h2[2][N], s[2][N]; long long m, n; map<int, bool> ans; int getnext(int p... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { vector<int> v; long long res, me = 0, mf = 0; for (int i = 0; i < n; i++) { int c; cin >> c; v.push_back(c); } long long res1 = 1000000 - v[0]; res = 1000007; ... |
#include <bits/stdc++.h> int n, m, l, x, oo = 1000000007, c[100005], a[100005], b[100005]; long long res = 1, ans; long long Exp(long long x, long long y) { long long res = 1; for (; y; y >>= 1, x = x * x % oo) if (y & 1) res = res * x % oo; return res; } int main() { scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; const double EXP = 1e-11; const int maxn = 2e5 + 10; int n; double a[maxn]; double a2[maxn]; double Judge(double x) { double sum1 = 0.0, sum2 = 0.0, sum3 = 0.0; for (int i = 1; i <= n; i++) a2[i] = a[i] - x; for (int i = 1; i <= n; i++) { sum... |
#include <bits/stdc++.h> using namespace std; int n, k; vector<bitset<7>> score; vector<bitset<7>> bvec(10); map<unsigned long, int> bmap; bool flag = false; long long ans = 0; vector<string> anss; int ccc = 0; int ans_tab[2001][10][2001]; bool valid(vector<bitset<7>>& s, int cur, int dig, int cnt... |
#include <bits/stdc++.h> using namespace std; const int N = 110; long long dp[N][N][N]; char s[N]; int a[N]; long long f[N]; void update(long long &x, long long y) { if (y == -1) return; if (x == -1 || x < y) x = y; } bool vis[N][N][N]; long long dfs(int l, int r, int p) { if (l > r) ret... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC optimize( unroll-loops ) using namespace std; void test_case() { int n; cin >> n; vector<int> arr(n); for (int i = 0; i < n; i++) cin >> arr[i]; vector<int> l(n), r(n); l[0] = 1; for (int i = 1; i < n; i++) { if... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int sq[504][504], sum[504][504], dp[2][504][504]; int main() { int n, m; ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> m; for (int i = 1; i < n + 1; ++i) for (int j = 1; j < m + 1;... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; scanf( %lld , &n); scanf( %lld , &k); long long int i, j; long long int val = 0, val1 = 0, val2 = 1; for (i = 1; i < k; i++) { val = (val * 10) + 9; val2 = val2 * 10; } val1 = (val * 10) + 9; ... |
#include <bits/stdc++.h> using namespace std; template <typename _Tp, typename _Up> bool maximize(_Tp &__a, _Up __b) { if (__a < __b) { __a = __b; return true; } return false; } template <typename _Tp, typename _Up> bool minimize(_Tp &__a, _Up __b) { if (__a > __b) { __a = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.