func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int MAX_N = 100100; int N, M; long long h[MAX_N], p[MAX_N]; inline long long calc(long long start, long long from, long long to) { if (to <= start) return start - from; if (from >= start) return to - start; long long left = start - from, right = ... |
#include <bits/stdc++.h> namespace in { char buf[1 << 21], *p1 = buf, *p2 = buf; inline int getc() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++; } template <typename T> inline void read(T &t) { t = 0; int f = 0; ... |
#include<bits/stdc++.h> #define N 200100 #define ll long long using namespace std; const ll inf=9223372036854775807; ll n,m; ll T; ll a[N]; ll maxx=-inf; ll ans; ll anss; int main(){ cin>>T; while(T--){ ans=0; maxx=-inf; cin>>n; scanf( %lld ,&a[1]); for(int i=2;i<=n;i++)... |
#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 / gcd(a, b) * b; } long long n, s1, v1, s2, v2; long long i, j, k, ans, p, q, m, num; inline long long cal_1() { return i * v1 + (n ... |
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> arr[100000 + 5]; int main() { cin >> n; int L = 0, R = 0; for (int i = 1; i <= n; i++) { cin >> arr[i].first >> arr[i].second; L += arr[i].first; R += arr[i].second; } int ans = abs(L - R); int id = 0; ... |
#include <bits/stdc++.h> using namespace std; long long n, p; long long w, d; int main() { cin >> n >> p >> w >> d; long long x, y = -1, z = -1; for (long long i = p / w; i >= max(p / w - d, (long long)0); i--) { x = i; if (p - x * w >= 0 && (p - x * w) % d == 0) { y = (p - x * w... |
#include <bits/stdc++.h> #define pb push #define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) using namespace std; typedef long long ll; typedef long double ld; typedef vector <ll> vll; typedef pair<ll,ll> pll; typedef vector <pair<ll,ll>> vpll; typedef vector <vll> vvll; ll n; ... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; a %= b; return gcd(b, a); } long long power(long long x, long long y, long long md = 1000000007) { long long res = 1; x %= md; while (y > 0) { if (y & 1) res = (res * x) % ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; bool check(int n, int l, int v1, int v2, int k, double mid) { double t0 = (l - v2 * mid) / (v1 - v2); if (t0 < -eps) return 0; double tb = mid - t0; if (tb < -eps) return 0; double tback = (v2 - v1) * tb / (v2 + v1) + tb; ... |
#include <bits/stdc++.h> using namespace std; struct LCA { int logn; vector<int> depth; vector<vector<int> > lca; vector<vector<int> > *edges; LCA(int n, vector<vector<int> > *edges) { logn = log(n) / log(2) + 1; depth.resize(n + 1, 0); lca.resize(n + 1, vector<int>(logn, 0)); ... |
#include <bits/stdc++.h> int main() { int N, L, i, count = 0, vivos = 0; int vet[1000000]; scanf( %d , &N); for (i = N - 1; i >= 0; i--) { scanf( %d , &vet[i]); } for (i = 0; i < N; i++) { if (count == 0) { count = vet[i]; vivos++; } else { count--; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int q, n, m; cin >> q; while (q--) { cin >> n >> m; string s; cin >> s; long long int a[n + 1], b[n + 1], zero = 0, one = 0; a[0... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { string ch; cin >> ch; long long int ans = 0; int x = 0, y = 0; set<pair<pair<int, int>, pair<int, int>>> s; pair<int, int> prev = {0, 0}; for (int i = 0; i < (int... |
#include<bits/stdc++.h> #define max(a,b) ((a)>(b)?(a):(b)) using namespace std; int n,m,k,x,y,z,dp[500039],l[500039],r[500039],now,a[500039],siz[500039],g[500039],f[500039]; void work(int n){ for(int i=1;i<=n;i++) scanf( %d ,&a[i]),siz[a[i]]++,l[a[i]]=l[a[i]]?l[a[i]]:i,r[a[i]]=i; for(int i=1;i<=n;i++)... |
#include <bits/stdc++.h> using namespace std; long long n, k, x, y, z, A[(1 << 17)], B[(1 << 17)], C[(1 << 17)], mmp[(1 << 17)], Comb[18][18]; long long O[(1 << 17)], Ans[4][(1 << 17)], S[4][(1 << 17)]; long long powmod(long long x, long long y = 998244353 - 2, long long p = 998244353) ... |
#include <bits/stdc++.h> using namespace std; int n, arr[1042], cc[1042]; vector<pair<int, int> > path; vector<pair<int, int> > ans; map<pair<long long, long long>, pair<int, int> > m; long long base = 1031, mod = 1000000007LL, mod2 = 1000000009LL; long long pows[1042] = {1}; pair<long long, long long> ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5 + 100000; int n, m, len_behind, len_front; struct TREE { int fg; int M11[3]; } T[maxn * 4]; inline int L(int &x) { return x << 1; } inline int R(int &x) { return x << 1 | 1; } void f_maintain(int root, int len) { int a = L(root... |
#include <bits/stdc++.h> using namespace std; bool SR(int &x) { return scanf( %d , &x) == 1; } bool SR(long long &x) { return scanf( %lld , &x) == 1; } bool SR(double &x) { return scanf( %lf , &x) == 1; } bool SR(char *s) { return scanf( %s , s) == 1; } bool RI() { return true; } template <typename I, typ... |
#include <bits/stdc++.h> using namespace std; int main() { string zbor1, zbor2; cin >> zbor1; int n, i, j; n = zbor1.length(); if (n < 10) { cout << NO ; return 0; } for (i = n - 1; i >= n - 10; i--) { zbor2 = zbor2 + zbor1[i]; } if (zbor2 == SECROFEDOC ) { ... |
#include <bits/stdc++.h> using namespace std; long long int abs(long long int a, long long int b) { if (a < b) { return -1 * (a - b); } return (a - b); } bool comp(long long int a, long long int b) { if (a > b) { return true; } return false; } int main() { int n, a, b... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, i, j; int max = INT_MIN; cin >> n; int a[n]; int b[n]; for (i = 0; i < n; i++) { cin >> a[i]; } for (j = n - 1; j >= 0; j--) { if (a[j] <= max) { ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1E9 + 7, INF = 2E18 + 5; const double PI = 2 * acos(0.0); const long double EPS = 1.0E-14; long long arr[1000005], arrFreq[1000005], arrAns[1000005]; vector<long long> vec; int main() { long long n, m, lcm = 1, sz = 0; cin >> n >>... |
#include <bits/stdc++.h> using namespace std; const int N = 1500010; int n, cnt, ans; int a[N], bug[N], v[N]; map<pair<int, int>, int> vis; bool check(int i) { if (!(i & 1)) { if (i < n) return a[i - 1] < a[i] && a[i + 1] < a[i]; else return a[i - 1] < a[i]; } else if (i ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1100000; int n, m; char a[MAXN], b[MAXN]; int s[MAXN], t[MAXN]; inline int id(int x, int y) { if (x < 1 || x > n || y < 1 || y > m) return 0; return (x - 1) * m + y; } bool check(int k) { for (int i = 1; i <= n; i++) { for ... |
#include <bits/stdc++.h> using namespace std; deque<int> A, B; long long p, i, j, k, n, m, aux; long long fact(int a) { long long f = 1; int i; for (int i = (int)(1); i <= (int)(a); ++i) f *= i; return f; } int main(void) { cin >> p; cin >> n; for (int i = (int)(1); i <= (int)(n)... |
#include <bits/stdc++.h> using namespace std; int n; int a[(int)(2 * 1e5 + 10)]; long long pa[(int)(2 * 1e5 + 10)]; long long sa[(int)(2 * 1e5 + 10)]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; pa[i] = 1ll * a[i] + pa[i - 1]; } for (int i = n; i >= 1; --i)... |
#include <bits/stdc++.h> using namespace std; int a[1000 + 3][1000 + 3]; int used[1000 + 3][1000 + 3]; int n; void dfs(int x, int y) { used[x][y] = 1; for (int i = 0; i <= 1001; i++) { if (!used[x][i] && a[x][i]) dfs(x, i); } for (int i = 0; i <= 1001; i++) { if (!used[i][y] && a[i... |
#include <bits/stdc++.h> using namespace std; namespace io { string separator = ; } template <typename T> inline void write(T x) { cout << x << io::separator; } template <typename T, typename... Args> inline void write(T x, Args... args) { write(x); write(args...); } inline void wri... |
#include <bits/stdc++.h> using namespace std; template <typename a> void SWAP(a &b, a &c) { a d = b; b = c; c = d; } long long power(long long a, long long b) { long long result = 1; while (b) { if (b & 1) result = a * result; a *= a; b >>= 1; } return result; }... |
#include <bits/stdc++.h> using namespace std; using ll = long long; template <class t, class u> void chmax(t& first, u second) { if (first < second) first = second; } template <class t, class u> void chmin(t& first, u second) { if (second < first) first = second; } template <class t> using v... |
#include <bits/stdc++.h> using namespace std; #define pi acos(-1) #define mod 1000000007 #define lli long long int #define li long int #define pb push_back #define mp make_pair #define ff first #define ss second #define nl n int main() { ios_base::sync_with_stdio(false), cin.tie(nullp... |
#include <bits/stdc++.h> using LL = long long; using ULL = unsigned long long; using namespace std; long long n, m; vector<long long> a; vector<pair<long long, long long> > vec; signed main() { ios::sync_with_stdio(false), cin.tie(NULL); cin >> n; a.resize(n, 0); vec.resize(n, {0, 0}); ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s >> t; reverse(s.begin(), s.end()); if (s == t) cout << YES ; else cout << NO ; } |
#include <bits/stdc++.h> using namespace std; const long long int Maxn = 20 + 5, Mod = 1e9 + 7, Inf = 1e9; int n, p[Maxn], ansss, m, fac[Maxn]; bool mrk[Maxn], mark[Maxn]; int ans[] = {1, 0, 18, 0, 1800, 0, 670320, 0, 734832000, 0, 890786230, 0, 695720788, 0, 150347555, 0... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const int pN = 1e6; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; void add(long long &x, long long y) { x += y; x %= MOD; } bool vis[MAXN]; int a[MAXN]; int main() { int n, k; cin >> n >> k; for (int ... |
#include <bits/stdc++.h> using namespace std; int n, m; long long data[100010], diff[100010], change[100010]; vector<vector<long long> > adj; vector<pair<long long, int> > vp; int main(void) { scanf( %d%d , &n, &m); adj.resize(n + 1, vector<long long>()); for (int i = 0; i < m; i++) scanf( %I64d... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) const char nl = n ; using namespace std; using ll = long long; using vi = vector<ll>; using vl = vector<ll>; using pii = pair<ll, ll>; using pll = pair<ll, ll>; using str = string; str to_string(char c) { return str(1... |
#include <bits/stdc++.h> using namespace std; int mp[100][100]; int cnt[100]; int main() { int n, x, y; cin >> n; while (cin >> x) { cin >> y; mp[x][y] = 1; mp[y][x] = 1; cnt[x]++; } for (int i = 1; i <= n; i++) { for (int j = i + 1; j <= n; j++) { if (!... |
#include <bits/stdc++.h> int n, m; std::vector<std::vector<int> > gr; std::vector<int> par; std::vector<bool> vis; std::vector<int> lev; void dfsgr(int v) { vis[v] = true; for (auto& ch : (gr[v])) { if (vis[ch]) continue; lev[ch] = lev[v] + 1; par[ch] = v; dfsgr(ch); } ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; inline void rd(int &x) { int k; int m = 0; x = 0; for (;;) { k = getchar(); if (k == - ) { m = 1; break; } if ( 0 <= k && k <= 9 ) { x = k - 0 ; break; } ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long n, k, t, m, q, flag = 0; long long po(long long k, long long n, long long ans, long long temp, long long ans1) { if (n == 0) return ans; while (temp <= n) { ans *= ans1; ans %= mod; ans1 ... |
#include<bits/stdc++.h> #include<unordered_map> #include<unordered_set> #define f(i,a,b) for( int i=a;i<=b;++i) #define ff(i,a,b) for( int i=a;i>=b;--i) #define debug(x) cerr << #x << : << x << << endl using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long doub... |
#include <bits/stdc++.h> const int N = 600000 + 7; using namespace std; char o[] = { I , E , A , O , U , Y }; bool mark[N]; long long sum[N]; long double ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; for (int i = 0; i < (((int)s.size())); i++) ... |
#include <bits/stdc++.h> using namespace std; struct node { long long x; bool s; node(long long a, bool b) { x = a, s = b; } }; bool operator<(node a, node b) { return a.x > b.x; } priority_queue<node> pq; int main() { int n; long long temp; cin >> n; long long ans = 0; for (... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; cin >> n; long long int a[100005] = {0}; for (int i = 1; i <= n; i++) cin >> a[i]; a[n + 1] = 0; for (int i = 1; i <= n; i++) { cout << a[i] + a[i + 1]; cout << ; } ... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long SZ = 107; const long long N = 1e6 + 7; const long long M = 1e4 + 7; long long n, m, c; void solve() { long long n; cin >> n; long long a[n]; vector<long long> b, c; for (long long i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; template <typename T> string tos(T a) { stringstream ss; string ret; ss << a; ss >> ret; return ret; } void read(int &_a) { int temp = scanf( %d , &_a); } void read(int &_a, int &_b) { int temp = scanf( %d %d , &_a, &_b); } void read(int &_... |
#include <bits/stdc++.h> using namespace std; int main() { int arr[1000], n, k, s = 0, c = 0, v = 0; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> arr[i]; } for (int i = 1; i <= n; i++) { if (arr[i] <= 8) { s = s + arr[i]; c++; if (s >= k) break; ... |
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); long long a[200002] = {}; long long b[200002] = {}; long long c[200002] = {}; string s = , ss = ; long long n, m, k, w; long long ans, ans1; long long mod = 1e9 + 7; int main() { cin.tie(0); cin.sync_with_stdi... |
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int MOD2 = MOD + 2; const int INF = (int)1e9; const long long LINF = (long long)1e18; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long lo... |
#include <bits/stdc++.h> using namespace std; list<pair<int, long long> > l; long long get(int x) { long long ans = 0; for (list<pair<int, long long> >::iterator it = l.begin(), e = l.end(); it != e; ++it) { ans = max(ans, it->second); if (x <= it->first) { break; } ... |
#include <bits/stdc++.h> using namespace std; int Map[30][30]; int N, M, T; void Swap(int x, int y) { for (int i = 1; i <= N; i++) { swap(Map[i][x], Map[i][y]); } } bool Find() { int ans = 0; for (int i = 1; i <= N; i++) { int s = 0; for (int j = 1; j <= M; j++) { i... |
#include <bits/stdc++.h> using namespace std; string func(pair<int, int> a, pair<int, int> b) { return to_string(a.first) + + to_string(a.second) + + to_string(b.first) + + to_string(b.second); } int nSmallFactor(int n, vector<int>& primes) { for (int prime : primes) { if (n... |
#include <bits/stdc++.h> using namespace std; const int NMax = 110000; struct edge { int num; edge *next; } * G[NMax], pool[NMax * 2]; int N, M, K, cant[NMax], L, deg[NMax], cnt[NMax], del[NMax], cur[NMax]; void Build(int x, int y) { edge *p = &pool[L++], *q = &pool[L++]; p->num = y; p->... |
#include <bits/stdc++.h> using namespace std; long long cumu[200005]; int main() { int n, k, x; while (scanf( %d %d , &n, &k) == 2) { memset(cumu, 0ll, sizeof cumu); int mn = INT_MAX; for (int i = 0; i < n; i++) scanf( %d , &x), cumu[x + 1] -= 1, mn = min(mn, x); cumu[1] = ... |
#include <bits/stdc++.h> long long x, y; long long gcd(long long a, long long b) { if (!b) { x = 1; y = 0; return a; } long long t1 = gcd(b, a % b); long long t2 = x; x = y; y = t2 - a / b * y; return t1; } int main() { long long a1, b1, a2, b2, l, r, g, t; ... |
#include <bits/stdc++.h> using namespace std; string s[105]; int n, m; int main() { long long l, r; cin >> l >> r; int digit1, digit2; digit1 = digit2 = 0; long long l1, r1; l1 = l; r1 = r; while (l1 != 0) { l1 /= 10; digit1++; } while (r1 != 0) { r1 /= ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> s(n, 0); vector<int> m(n, 0); map<int, int> freq, freq2; string sher, mori; cin >> sher; cin >> mori; for (int i = 0; i < n; i++) { s[i] = sher[i] - 0 ; } for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; const int N = 5100; const int oo = 1e9; const int MX = 100000000; const int FF = 33000; int n, m, a[N], gc[N]; int dp[5010], pre[5010]; map<int, bool> bad; map<int, int> cache; vector<int> prime; bool mark[FF + 200]; int gcd(int a, int b) { return !b... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, a, b, dp[200005][2]; cin >> n >> a >> b; string t; cin >> t; memset(dp, 0x3f, sizeof(dp)); dp[0][0] = b; for (int i = 0; i < n; i++) { if (t[i] == 1 ) dp[i + 1][1] = dp[i][1] + a + 2 * b; else ... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, m, ans; cin >> n >> m; vector<long long> ar(n); for (long long i = 0; i < n; i++) cin >> ar[i]; sort(ar.begin(), ar.end()); ans = 1; if (n > m) { cout << 0; return; } for (long long i = 0; i < n... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const int mod = 1e9 + 7; const int N = 1234; int n, m; long long k; int a[N][N], h[N * N], p[N * N]; long long b[N][N]; bool used[N][N]; vector<pair<int, int> > go = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; bool check(int x, int y) { re... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline void read(T &f) { f = 0; T fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fu = -1; c = getchar(); } while (c >= 0 && c <= 9 ) { f = (f << 3) + (f << 1) + (c & 15); ... |
#include <bits/stdc++.h> using namespace std; struct item_t { int cost; int gain; int when; bool operator<(const item_t& other) const { return when < other.when; } bool operator<(const int t) const { return when < t; } } item[4000]; bool operator<(int v, const item_t& item) { return v < item... |
#include <bits/stdc++.h> using namespace std; void debug_out() { cerr << endl; } template <class T> ostream& prnt(ostream& out, T v) { out << v.size() << n ; for (auto e : v) out << e << ; return out; } template <class T> ostream& operator<<(ostream& out, vector<T> v) { return prnt(ou... |
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 1; int a[N]; int main() { float n, x, y; cin >> x >> y; printf( %.12f , (y * y - x * x) / (2 * x)); } |
#include <bits/stdc++.h> using namespace std; string lines[10000]; int scheme[4]; int quart = -1; bool is_vowel(char c) { return c == a || c == e || c == i || c == o || c == u ; } bool rhyme(int s, int a, int b) { int A = lines[s + a].length() - scheme[a]; int B = lines[s + b].length(... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long long INF = 1e15; using Graph = vector<vector<long long>>; signed main() { long long T; cin >> T; for (long long t = 0; t < T; t++) { long long N; cin >> N; vector<long long> A(N); for... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; struct node { int v, next; } p[200005 << 1]; int head[200005], n, k; long long dp[200005][10], size[200005], ans; void dfs(int x, int fa, int depth) { size[x] = dp[x][depth % k] = 1; for (int i = head[x]; ~i; i = p[i].next)... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = 1 << 20 | 10; const int mod = 1e9 + 7; long long n, m, sum; int a[M]; int main() { scanf( %lld%lld , &n, &m); for (int i = 1; i <= n; i++) a[i] = i, sum += i; if (sum > m) return puts( -1 ), 0; for (int i = 1, j = n; i... |
#include <bits/stdc++.h> using namespace std; const int Dian = 200005; const int Bian = Dian * 2; const int M = Dian; const int Segment_Size = Dian * 4; int fir[Dian], ne[Bian], to[Bian], cnt, n, m; int dp[Dian], depth[Dian], fa[Dian], Bigson[Dian], top[Dian], S[Dian], dep[Dian], info[Dian]; struc... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long t; cin >> t; while (t--) { long long n, i, j; string s; cin >> s; long long x; cin >> x; n = s.length(); strin... |
#include <bits/stdc++.h> using namespace std; inline long long getnum() { char c = getchar(); long long num, sign = 1; for (; c < 0 || c > 9 ; c = getchar()) if (c == - ) sign = -1; for (num = 0; c >= 0 && c <= 9 ;) { c -= 0 ; num = num * 10 + c; c = getchar(); } ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, ar[N]; char mark[N] = {}; int sz[N] = {}; priority_queue<pair<int, int>, vector<pair<int, int> > > pq; int main(void) { cin.tie(0); ios::sync_with_stdio(0); cin >> n; for (int i = 0; i < n; ++i) cin >> ar[i]; f... |
#include <bits/stdc++.h> using namespace std; const int N = 5 * 1e5 + 10; int n, a[N]; int s[] = {4, 8, 15, 16, 23, 42}; int counts[50]; int mu[7]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } i... |
#include <bits/stdc++.h> using namespace std; const int N = 5e2 + 10; int ans, mac, n; int main() { ios_base::sync_with_stdio(false); cin >> n; while (ans < n) { mac += 5; int x = mac; while (x % 5 == 0) { x /= 5; ans++; } } if (ans == n) { cout ... |
#include <bits/stdc++.h> using namespace std; const long long N = 1000000007; long long q; long long md[255][255] = {0}; long long a[500005] = {0}; int main() { long long op, x, y; scanf( %lld , &q); while (q--) { scanf( %lld %lld %lld , &op, &x, &y); if (op == 1) { for (long... |
#include <bits/stdc++.h> using namespace std; int n, d[22]; int f[22], g[22], L[22], memF[22]; void moveG(int n, int a, int b, int c) { if (n == 0) return; moveG(n - L[n], a, c, b); for (int i = 0; i < L[n]; i++) printf( %d %d n , a, c); moveG(n - L[n], b, a, c); } void moveF(int n, int a, i... |
#include <bits/stdc++.h> using namespace std; long long p; long long base; char s[20]; long long a; long long d; int main(int argc, const char* argv[]) { int T; cin >> T; while (T--) { base = 1989; d = 10; scanf( %s , s); int i; for (i = 0, a = 0; s[i + 4] >= 0 ... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; vector<vector<pair<int, int>>> g; vector<pair<int, pair<int, int>>> edg; int cp[100010]; int find(int x) { return cp[x] = cp[x] == x ? x : find(cp[x]); } void union_(int x, int y) { cp[find(x)] = find(y); } int h[100010]; int ... |
#include <bits/stdc++.h> using namespace std; struct NODE { char w[4]; }; NODE tmp; vector<NODE> st, stt; bool use[10]; int bull, cow; char ss[6]; void back(int index) { if (index == 4) { int i, j, b, c; for (i = 0, b = 0, c = 0; i < 4; ++i) for (j = 0; j < 4; ++j) ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t, a, b; cin >> t; while (t--) { cin >> a >> b; if (a == b) { cout << 0 << n ; } else if (abs(a - b) <= 10) { cout << 1 << n ;... |
#include <bits/stdc++.h> using namespace std; const int M = 100010; long long MAX = 0; vector<int> maxs; vector<int> A[M]; map<pair<int, int>, int> mep; map<pair<int, int>, int> tmpmep; map<int, vector<pair<int, int> > > edges; int weight[M]; int parent[M]; int compsize[M]; int visited[M]; int... |
#include <bits/stdc++.h> using namespace std; int n, k; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; vector<vector<int>> g(n); for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--; b--; g[a].push_back(b); g[... |
#include <bits/stdc++.h> using namespace std; const double Pi = acos(-1.0); const long long MAXN = 1e6 + 5; long long n, m, t; struct NODE { long long a, b; } v[MAXN]; long long cmp1(NODE a, NODE b) { return a.a < b.a; } long long a[MAXN], b[MAXN]; long long q[MAXN]; int main() { cin >> t; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, k, dances = 0, a[250][2]; cin >> n >> m; dances = m + n - 1; for (i = 0; i < m; i++) { a[i][0] = 1; a[i][1] = i + 1; } k = 2; for (j = i; j < dances; j++) { a[j][0] = k; a[j][1] = 1; ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9 + 100; const long double eps = 1e-11; const long double pi = acos(-1.0L); int myrand() { return rand(); } unsigned rdtsc() { unsigned ans; asm( rdtsc : =a (ans)); return ans; } int rnd(int x) { return myrand() % x; } ... |
#include <bits/stdc++.h> using namespace std; class mat { public: long long a, b, c, d; }; mat a; long long n, k, l, m, step, res; long long power(long long a, long long b); mat mult(mat a, mat b); mat power1(mat a, long long n); int main() { cin >> n >> k >> l >> m; step = power(2, n);... |
#include <bits/stdc++.h> using namespace std; const long long int MOD = 1000000007; const long long int ll_MAX = 1e15; long long int fast_expo(long long int x, long long int p) { if (p == 0) return 1; else if (p % 2 == 0) { long long int t = fast_expo(x, p / 2) % MOD; return (t * t) % ... |
#include <bits/stdc++.h> using namespace std; int n, k, tot, arr[105], sum[100050][105], a[100050], s[105]; bool Solved(int x, int y) { for (int i = 1; i <= tot; ++i) if (sum[y][i] - sum[x - 1][i] < s[i]) return false; return true; } int main() { long long ans; scanf( %d%d , &n, &k); ... |
#include <bits/stdc++.h> int main() { int n, m, x, y, it; int64_t r, min, max, ser, k; std::cin >> n >> m >> k >> x >> y; std::vector<std::vector<int64_t>> serg(n); if (n == 1) { min = k / m; max = min + (k % m != 0); ser = min + (k % m - y >= 0); } else { r = k % (2 * ... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; int n = s.size(); vector<int> seq(n + 1, 0); vector<int> ind; for (int i = 1; i <= n; i++) { if (s[i - 1]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; bool vis[maxn]; int n, m, k, p[maxn], a[maxn]; char s[maxn][maxn]; void func(int x, int y) { --m; if (x <= y) { s[m][x] = s[m][y] = / ; } else { s[m][x] = s[m][y] = ; } } int main() { scanf( %d , &n... |
#include <bits/stdc++.h> using namespace std; int size(long long a) { int c = 0; while (a != 0) { c++; a /= 10; } return c; } int main() { long long a, b, c; cin >> a >> b; long long s = size(b), ns = 1; for (int i = 1; i <= s; i++) ns *= 10; s = ns; while (b ... |
#include <bits/stdc++.h> using namespace std; const int M = 1e9 + 7; const int MOD = 1e9 + 7; const double PI = 3.141592653589793238460; long long power(long long a, long long b) { long long res = 1; if (a == 0) return 0; if (a == 1) return 1; for (; b > 0; b >>= 1) { if (b & 1) res = (r... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, a; cin >> x >> y; vector<int> v; vector<int> v2; for (int i = 0; i < x; i++) { cin >> a; v.push_back(a); } for (int i = 0; i < y; i++) { cin >> a; v2.push_back(a); } int key = 0, ct = 0, ... |
#include <bits/stdc++.h> using namespace std; long long n, k, t = 0, a, e = 0; int main() { cin >> n >> k; for (long long i = 1; i <= n; i++) { cin >> a; if (i > 1 && t - (n - i) * a * (i - e - 1) < k) { cout << i << n ; e++; } else t += a * (i - 1 - e); } ... |
#include <bits/stdc++.h> using namespace std; const int maxx = 1e6 + 100; vector<pair<int, int> > in[maxx], out[maxx]; struct node { int l; int r; long long sum; long long num; } p[maxx << 2]; int n, m, k; void init() { for (int i = 0; i <= n; i++) { in[i].clear(); out[i].c... |
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf( %d , &t); while (t--) { int n; scanf( %d , &n); if (n == 1 || n == 2) printf( 1 n ); else if (n == 3) printf( 2 n ); else { if (n % 2 == 1) printf( %d n , (n - 1) / 2 ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( sse4 ) using namespace std; template <typename T> void etch(T V) { for (auto x : V) cout << x << ; cout << n ; } vector<string> vec_splitter(string s) { s += , ; vector<string> res; while (!s.empty()) { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.