func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n; if (n % 2 == 1) m = (n / 2) * (n / 2 + 1); else m = (n / 2) * (n / 2); cout << m << endl; for (int i = 1; i <= n / 2; i++) { for (int j = n / 2 + 1; j <= n; j++) { cout << i << << j <... |
#include <bits/stdc++.h> using namespace std; long long ar[1000001] = {}; long long n, a, b; void shift(long long l, long long r) { for (long long f = (long long)(l); f <= (long long)(r - 1); ++f) { swap(ar[f], ar[f + 1]); } } void Do(long long x, long long y) { long i = 0; for (long l... |
#include <bits/stdc++.h> using namespace std; long long temp = 0, r, l, w, k = 0, m1, e, p, q, ans = 0, k1 = 0, k2 = 0, d = 0, a = 0, b = 0, s = 0, x, y, min1 = 1000000010, max1 = 0, m, c = 0, t = 0, i, n, c1 = 0, tot = 0, t1, k4 = 0, c2 = 0, j = 0, k3 = 0; char ch, ch1, ch2; string s1, ... |
#include <bits/stdc++.h> int main() { int t; scanf( %d , &t); while (t--) { int a1, b1, flag1, flag2, flag3, flag4; scanf( %d%d , &a1, &b1); int a2, b2; scanf( %d%d , &a2, &b2); flag1 = flag2 = flag3 = flag4 = 0; if (a1 == a2) { flag1 = ((b1 + b2) == a1) ? 1 : 0... |
#include <bits/stdc++.h> int inp() { char c = getchar(); while (c < 0 || c > 9 ) c = getchar(); int sum = 0; while (c >= 0 && c <= 9 ) { sum = sum * 10 + c - 0 ; c = getchar(); } return sum; } struct BIT { int f[2010]; void init() { memset(f, 0, sizeof(f)); } ... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } template <class T> inline void gn(T &first) { char c, sg = 0; while (c =... |
#include <bits/stdc++.h> using namespace std; void rc(char &a) { a = 0; register int x = getchar_unlocked(); while (x < a || x > z ) { if (x == n ) { a = 0 ; return; } x = getchar_unlocked(); } a = x; } const int maxn = 100100; int key; int main() ... |
#include <bits/stdc++.h> using namespace std; template <typename T> inline string tostring(const T &x) { ostringstream os; os << x; return os.str(); } inline int toint(const string &s) { istringstream is(s); int x; is >> x; return x; } inline int todecimal(string s) { int a... |
#include <bits/stdc++.h> using namespace std; vector<vector<int>> v; int res; int countOne(vector<vector<int>> &a, int i, int j) { int res = 0; if (a[i][j] == 1) res++; if (a[i + 1][j] == 1) res++; if (a[i][j + 1] == 1) res++; if (a[i + 1][j + 1] == 1) res++; return res; } void switc... |
#include <bits/stdc++.h> using namespace std; long long x, d, v; vector<long long> res; void solve() { cin >> x >> d; res.clear(); v = 1; for (int j = 0; j <= 30; j++) { if ((1 << j) & x) { for (int k = 1; k <= j; k++) res.push_back(v); v += d + 1; res.push_back(v);... |
#include <bits/stdc++.h> using namespace std; int main() { int x, big, small, counter = 0, y, b = 0; cin >> x; int a[x]; for (int i = 0; i < x; i++) { cin >> y; a[i] = y; } big = max_element(a, a + x) - a; for (int i = 0; i < big; i++) { swap(a[big - i], a[big - 1 - i])... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); int main() { long long m, n, i; while (cin >> n >> m) { long long a[n + 1], b; a[0] = 0; for (i = 0; i < n; i++) { cin >> a[i + 1]; a[i + 1] += a[i]; } for (i = 0; i < m; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long max(long long a, long long b) { if (a > b) { return a; } else { return b; } } long long min(long long a, long long b) { if (a < b) { return a; } else { return b; } } long long n, m, p; int a[200003], b[... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:102400000,102400000 ) 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 +... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; int a[n], ans = 0; for (int i = (0); i < (n); ++i) cin >> a[i]; for (int l = (0); ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 1; cin >> n; for (int i = 0; i < n; i++) { if (a <= 2) { cout << a ; a++; } else if (a > 2 && a <= 4) { cout << b ; a++; } else { cout << a ; a = 2; } } ... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimize( unroll-loops ) using namespace std; template <typename T> bool mycomp(T x, T y) { return (x == y); } bool paircomp(const pair<long long int, long long int> &x, const pair<long... |
#include <bits/stdc++.h> using namespace std; int fx[] = {1, -1, 0, 0}; int fy[] = {0, 0, 1, -1}; int main() { long long n; cin >> n; if (n == 1) cout << 1; else if (n == 2) cout << 3; else { n += 3; long long a = 0, b = 1; for (int i = 2; i <= n; i++) { ... |
#include <bits/stdc++.h> using namespace std; const int N = 301; string s[N][N]; vector<pair<pair<int, int>, pair<int, int> > > f(int n, int k) { vector<pair<pair<int, int>, pair<int, int> > > ans; pair<int, int> f0 = {1, 0}, f1 = {0, 1}; int i, j, l; for (i = 0; i < s[0][0].size(); ++i) i... |
#include <bits/stdc++.h> using namespace std; unsigned long long mod = 1e9 + 7; unsigned long long ncr(long long int n, long long int k) { unsigned long long res = 1; if (k > n - k) k = n - k; for (int i = 0; i < k; ++i) { res *= (n - i); res /= (i + 1); res = res; } return r... |
#include <bits/stdc++.h> using namespace std; int h; const int mx = 2e5 + 5; vector<int> a(mx); void eval1() { cout << 0; int x = 1, y = 1; for (int i = 1; i <= h; i++) { for (int j = 0; j < a[i]; j++) { cout << << x; y++; } x = y; } cout << endl; } ... |
#include <bits/stdc++.h> using namespace std; const int M = 10; set<int> s[M]; int n, p[M]; bool check(int x) { vector<int> b; while (x) { b.push_back(x % 10); x /= 10; } if (b.size() > n) return false; for (int i = 0; i < b.size(); i++) if (s[p[i]].find(b[i]) == s[p[i]].... |
#include <bits/stdc++.h> using namespace std; int n; int a[220000]; int s[220000]; int g[220000]; int main() { scanf( %d , &n); for (int i = 0; i < n; ++i) { scanf( %d%d , s + i, g + i); a[i] = s[i] + g[i]; } for (int i = 0; i < n - 1; ++i) a[i + 1] = min(a[i + 1], a[i] + 1); ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i]; int maxCap = b[0], curCap = b[0]; for (int i = 1; i < n; ++i) { curCap = curCap ... |
#include <bits/stdc++.h> using namespace std; template <typename Tp> inline void read(Tp &x) { static char c; static bool neg; x = 0, c = getchar(), neg = false; for (; !isdigit(c); c = getchar()) { if (c == - ) { neg = true; } } for (; isdigit(c); c = getchar()) { ... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 3; long long n, ans, sz[N], up[N], down[N]; vector<long long> q[N]; void dfs1(long long v, long long p) { sz[v] = 1; for (auto i : q[v]) { if (i != p) { dfs1(i, v); sz[v] += sz[i]; down[v] += down[i] ... |
#include <bits/stdc++.h> using namespace std; int n; int x[411111], d[411111]; int go[20][411111], w[20][411111]; int ma[20][411111]; int comp(int a, int b) { if (a == -1) return b; if (b == -1) return a; if (x[a] + d[a] > x[b] + d[b]) return a; return b; } int main() { cin >> n; ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e6 + 5; struct T { int l, r, i; bool operator<(T const& other) { return (l == other.l ? r < other.r : l < other.l); } }; int con[MAX][2]; pair<int, int> num[2 * MAX]; int main() { ios_base::sync_with_stdio(false); cin... |
#include <bits/stdc++.h> using namespace std; char BUF_I[1048576], *S_I = BUF_I, *T_I = BUF_I; struct Input { Input() {} inline Input &operator>>(char &c) { return (c = ((S_I == T_I) && (T_I = (S_I = BUF_I) + fread(BUF_I, 1, 1048576, stdin), S_I... |
#include <bits/stdc++.h> using namespace std; long long c1, c2, c3, c4, n, m, i, kol1, kol, ans, ans1; int main() { cin >> c1 >> c2 >> c3 >> c4; cin >> n >> m; long long a[n + 1], b[m + 1]; for (i = 1; i <= n; i++) cin >> a[i]; for (i = 1; i <= m; i++) cin >> b[i]; for (i = 1; i <= n; i++)... |
#include <bits/stdc++.h> #pragma GCC optimize(3, Ofast , inline ) using namespace std; const long long maxn = (long long)4e5 + 5; const long long mod = 1000000007; const long long inf = 0x3f3f3f3f; long long a[maxn], b[maxn], n, ans; bool cal(long long L, long long R) { long long sum = 0; for (l... |
#include <bits/stdc++.h> int main() { int l, b; std::cin >> l >> b; if (l * b % 2 == 0) { std::cout << (l * b) / 2; return 0; } std::cout << ((l * b) - 1) / 2; } |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int sz2 = 5e5 + 1; int fact[sz2]; int inv_fact[sz2]; int mul(int a, int b) { return (long long)a * b % mod; } int add(int a, int b) { int res = (long long)a + b; if (res < 0) res += mod; else if (res > mod) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n1, n2, k1, k2; cin >> n1 >> n2 >> k1 >> k2; if (n1 > n2) cout << First << endl; else if (n1 == n2) cout << Second << endl; else cout << Second << endl; return 0; } |
#include <bits/stdc++.h> int main() { int n, m, k; while (scanf( %d%d , &n, &m) != EOF) { int ans = n / m; k = n % m; for (int i = 1; i <= m; i++) { if (i <= m - k) { printf( %d , ans); } else { printf( %d , ans + 1); } if (i != m) { ... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const int N = 710; string s; int n, t[N]; stack<int> st; struct node { long long f[3][3]; void init() { for (int i = 1; i <= 2; i++) f[i][0] = f[0][i] = 1; } node() { memset(f, 0, sizeof(f)); } void mergein... |
#include <bits/stdc++.h> #pragma optimization_level 3 #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx ) using namespace std; const long long N = 1e6 + 5; const long long mod = 1e9 + 7; const long long INF = 0x7f7f7f... |
#include <bits/stdc++.h> using namespace std; vector<vector<long long> > g; vector<vector<pair<long long, long long> > > updates; vector<long long> tree; vector<long long> ans; long long n; void update(long long v, long long l, long long r, long long al, long long ar, long long val) { if... |
#include <bits/stdc++.h> using namespace std; int flag[3000500]; int dp[200050]; int maxx[200050]; int ans[200050]; stack<int> st; int main() { string s; cin >> s; int n = s.size(); for (int i = 0; i < n; i++) { ans[i] = 0; if (s[i] == 1 ) st.push(i); if (s[i - 1] == 1 ... |
#include <bits/stdc++.h> using namespace std; int n; int C[1 << 12], A[1 << 12], B[1 << 12], LA[1 << 12], LB[1 << 12]; int main() { int i, s = 0; scanf( %d , &n); n = (1 << n); for (i = 0; i < n; i++) { scanf( %d , &C[i]); s ^= C[i]; } if (s) { puts( Fou ); return... |
#include <bits/stdc++.h> using namespace std; inline long long calc(long long x, long long k) { if (x < 0) return 0LL; return x / k + 1LL; } int main() { long long k, a, b; scanf( %lld%lld%lld , &k, &a, &b); if (a <= 0 && b <= 0) { a = abs(a), b = abs(b); printf( %lld n , calc(a,... |
#include <bits/stdc++.h> using namespace std; int n, w, csets; int weights[1001]; int beauties[1001]; int ranksz[1001]; int parents[1001]; bool superprnt[1001]; vector<vector<int>> setlist; vector<int> beautysum; vector<int> wtsum; map<int, int> setidmap; vector<vector<int>> dpmap; int find_pa... |
#include <bits/stdc++.h> using namespace std; int s[65] = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1,... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; long long int a[n]; for (auto i = 0; i <= n - 1; i++) cin >> a[i]; sort(a, a + n); for (auto i = n - 1; i >= 0; i--) { if (a[i] <= i + 1) { cout << i + 2 << n ; return; } ... |
#include <bits/stdc++.h> using namespace std; const char E = n ; int main() { set<string> a; string s; cin >> s; a.insert(s); int n = s.length(); for (int i = 1; i <= n + 1; i++) { char z = s[n - 1]; for (int j = n; j >= 1; j--) { s[j] = s[j - 1]; } s[0] =... |
#include <bits/stdc++.h> using namespace std; bool query(int x, int y) { cout << ? << x << << y << endl; char resp; cin >> resp; if (resp == e ) exit(0); return resp == x ; } void answer(int v) { cout << ! << v << endl; return; } void solve() { int k = -1; ; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, t, i, c = 0, s, x, y, u; cin >> n >> t; if (t < 10) { for (i = 0; i < n; i++) cout << t; } else { s = t / 10; c++; while (1) { s = s / 10; c++; if (s == 0) break; } ... |
#include <bits/stdc++.h> using namespace std; int flag[13], change[13]; bool is_leap(int y) { if (y % 100 == 0) return y % 400 == 0; else return y % 4 == 0; } int main() { memset(flag, 0, sizeof(flag)); memset(change, 0, sizeof(change)); int y; cin >> y; while (1) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 2147483647; const long long LLINF = 9223372036854775807LL; int m; const int mod = 1000000007; struct matr { int a[60][60]; matr() { memset(a, 0, sizeof(a)); } }; matr mul(matr m1, matr m2) { matr res; for (int i = 0; i < m; ++... |
#include <bits/stdc++.h> using namespace std; int main() { long long A, B, x, y, z; cin >> A >> B >> x >> y >> z; for (int i = 0; i < x; i++) A = A - 2; for (int i = 0; i < y; i++) { A--; B--; } for (int i = 0; i < z; i++) B = B - 3; long long a = 0, b = 0; if (A < 0) a =... |
#include <bits/stdc++.h> using namespace std; template <typename T, typename U> inline void smin(T &a, U b) { if (a > b) a = b; } template <typename T, typename U> inline void smax(T &a, U b) { if (a < b) a = b; } int power(int a, int b, int m, int ans = 1) { for (; b; b >>= 1, a = 1LL * a *... |
#include <bits/stdc++.h> using namespace std; const int N = 1000005, mod = 1000000007; int ar[N]; inline int lowbit(int x) { return x & (-x); } void add(int i, int v) { for (; i < N; i += lowbit(i)) { ar[i] += v; if (ar[i] >= mod) { ar[i] %= mod; } } } int sum(int i) { ... |
#include <bits/stdc++.h> using namespace std; long long a[1000010]; int main() { int n; scanf( %d , &n); long long sum = 0; for (int i = 1; i <= n; ++i) { scanf( %lld , &a[i]); sum += a[i]; } if (sum <= 1) { printf( -1 n ); return 0; } long long ans = 999999... |
#include <bits/stdc++.h> using namespace std; const int maxN = 1000009; map<string, int> mapa; int n, m, k, a, parent[maxN], used[maxN], rozmiar[maxN], centr[maxN], q; vector<int> graf[maxN]; string s, s1; void DFS(int start) { used[start] = 1; for (int i = 0; i < graf[start].size(); i++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int a; cin >> a; string s; cin >> s; map<long long, long long> mp; long long ans = 0; for (int i = 0; i < s.size(); i++) { long long c = 0; for (int j = i; j ... |
#include <bits/stdc++.h> using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int main() { fastio(); long long int T = 1; cin >> T; for (long long int test = 1; test <= T; test++) { long long int n, m, k, ans, cnt, sum; ans = 0; cnt = ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a, b, c, d; cin >> n >> k >> a >> b >> c >> d; if (n == 4 || k < n + 1) cout << -1 << endl; else { int cur = 1; vector<int> ret; ret.push_back(a); ret.push_back(c); while (cur == a || cur == b ||... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int k; cin >> k; int sz = s.size(); string land; bool equal; int begin, lenth, idx, res = 0, end; for (int i = 0; i < sz; i++) { begin = i; land = ; for (int j = i; j < sz; j++) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; int cnt = 0; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i < n - 1; i++) { if (a[i] == 0) { if (a[i + 1] == 1 && a[i - 1] == 1) { if (i + 2 < n) { if (a[i + ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; int a[m]; for (int i = 0; i < m; ++i) a[i] = 1e7; for (int i = 0; i < n; ++i) { int r, c; cin >> r >> c; a[r - 1] = min(a[r - 1], c); } int ans = 0; for (int i = 0; i < m; ++... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 5; char C[MAXN][20][20]; long long aans[MAXN]; struct node { long long u, v, val, way; node() {} node(long long a, long long b, long long c) { u = a; v = b; val = c; } }; vector<node> v; vector<i... |
#include <bits/stdc++.h> using namespace std; int main() { double a1, b1, c1, a2, b2, c2; cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2; if (b1 || b2) { if ((!a1 && !b1 && !c1) || (!a2 && !b2 && !c2)) { cout << -1; return 0; ; } if ((!a1 && !b1) || (!a2 && !b2)) { ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; int h[5005]; int dp[5005][2505][2]; void test_case() { int n; scanf( %d , &n); for (int i = 1; i <= n; ++i) scanf( %d , &h[i]); memset(dp, INF, sizeof(dp)); dp[0][0][0] = 0; dp[1][0][0] = 0; dp[1][1][1] = 0; ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:1024000000 ) using namespace std; struct N { int x, y; }; queue<N> q; char Map[2010][2010]; int jx[] = {-1, 0, 1, 0}; int jy[] = {0, 1, 0, -1}; char CalChar(int dir) { if (dir == 0) return v ; if (dir == 1) return < ; if (dir =... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int n = s.length(); if (n <= 10) { cout << s << endl; } else { cout << s.at(0); cout << n - 2; cout << s.at(n - 1) << endl; } ... |
#include <bits/stdc++.h> using namespace std; long long a[1007]; long long cnt[1007]; long long ncr[1007][1007]; long long MOD = 998244353; int main() { long long n, res = 0, x; scanf( %I64d , &n); ; for (long long i = 1; i <= n; ++i) scanf( %I64d , &a[i]); ; for (int i = 0; i < 1000... |
#include <bits/stdc++.h> using namespace std; using LL = long long; template <typename T> using V = vector<T>; template <typename T, typename S> using P = pair<T, S>; template <class T> using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>; using LD = long double; template <typename T,... |
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n == 1) { printf( a na nb nb n ); continue; } if (n % 2 == 0) { for (int i = 0; i < 4; i++) { for (int j = 0; j < n; j++) { if (i % 4 < 2) { ... |
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9 + 7; const int N = (int)3e5 + 4; const int M = 1001; int n, k; int a[6]; double ans; void f(int s) { if (s == k) { for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (a[i] > a[j]) { ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long test, i, j, xy, flag = 0, n, u, count, d, o1 = 0, o2 = 0, s, e, l, r, x, y, m, z, max1, x1, y1, k, x2, y2, z1, sum, f, ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long s, x; cin >> s >> x; s -= x; if (s % 2 || s < 0) { cout << 0 << n ; return 0; } s >>= 1; bool ok = true; for (int i = 50; i >= 0; --i) if (s & (1... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k, a[105], b[105], i, q, j, f, x, c = 0; double s = 0, s1 = 0, min = -1, max = -1; cin >> n >> k; for (i = 1; i <= n; i++) cin >> a[i]; cin >> q; for (i = 1; i <= q; i++) { f = 0; s = 0; for (j = 1; j <= n / ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using u64 = uint64_t; using u32 = uint32_t; using pi = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vvi = vector<vi>; using vpi = vector<pi>; static conste... |
#include <bits/stdc++.h> using namespace std; void solve() { long long int n; cin >> n; if (n > 2) { for (long long int i = 0; i < n - 1; i++) cout << 2 << ; cout << 1 << endl; } else cout << -1 << endl; } void testcase() { int t; cin >> t; while (t--) { so... |
#include <bits/stdc++.h> using namespace std; const int MOD(1000000007); const int INF((1 << 30) - 1); const int MAXN(); int main() { long long k, b, t; int n; cin >> k >> b >> n >> t; long long z = 1; int num = 0; while (z <= t) { z = z * k + b; num++; } printf( %d... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using uint = unsigned int; const int NMax = 1e2 + 5; const ll inf_ll = 1e18 + 5; const int inf_int = 1e9 + 5; const int mod = 100003; using zint = int; void getABC(char* sir, int& a, int& b, int& c) {... |
#include <bits/stdc++.h> using namespace std; int n, k; int judge(int n) { if (n == 2 || n == 3) return 1; for (int i = 2; i <= sqrt(n); i++) if (n % i == 0) return 0; return 1; } int main() { int i, j, m; scanf( %d , &n); if (judge(n)) printf( 1 n%d n , n); else if (ju... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int MOD = 1e9 + 7; int n, revfact[N << 1], fact[N << 1]; int mul(int, int); int sum(int, int); int pow(int, int); int choose(int, int); int32_t main() { cin >> n; fact[0] = 1; for (int i = 1; i < 2 * n + 3; i++) fa... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, x, t = 1, y; cin >> a >> b; x = abs(a - b); if (x % 2 != 0) t = 0; x = (x / 2); y = (x * (x + 1)) / 2; y *= 2; if (!t) x++, y += x; cout << y << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; using namespace std; using ll = long long; using ld = long double; const int MOD = 1e9 + 7, inf = 1e9, N = 2e5 + 1; const ll INF = 1e18; ld tic, tac; void solve() { int n, count = 0; cin >> n; int i, a[n]; for (i = 0; i < n; i++) { cin ... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1000100; const int off = 1 << 19; const int inf = 1e9; int a[MAX], s[MAX], c[MAX]; pair<int, int> T[2 * off]; int n, k; pair<int, int> getmax(int i, int lo, int hi, int a, int b) { if (lo >= b || hi <= a) return {-inf, -1}; if (lo >= ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 500005; const int inf = 100000000; struct elem { long long val; int l, r; }; struct V { long long val; int ind; }; bool compare(V x, V y) { if (x.val < y.val) return true; if (x.val == y.val && x.ind < y.ind) return t... |
#include <bits/stdc++.h> using namespace std; struct Edge { int u, v; int c; int w; int id; bool use; }; bool operator<(const Edge& l, const Edge& r) { return l.w < r.w; } class Node { int depth; pair<int, int> w; Node* parent; public: Node() : depth(0), w(0, -1), par... |
#include <bits/stdc++.h> int star[100005]; int scnt; int pack[100005]; int pcnt; int unit(int x) { if (x > 0) return x; return 0; } int check(int time) { int i; int sat = 0; for (i = 1; i <= pcnt; i++) { if (sat >= star[scnt]) return 1; int l = 1, r = scnt, mid, idx; ... |
#include <bits/stdc++.h> using namespace std; const int mxN = 2e5; int n, a[mxN], k; void solve() { long long n; cin >> n; if (n == 0) { cout << 1 << endl; return; } if (n % 4 == 1) { cout << 8 << endl; } else if (n % 4 == 2) { cout << 4 << endl; } else if (n ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; long long x, a[N], b[N]; long long n, k; int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + 1 + n); b[1] = a[1]; int j = 2; for (int i = 2; i <= n; i++) { if (a[i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 100; int a[maxn]; long long dp[maxn][2]; int get1(long long n) { int sum = 0; while (n != 0) { if ((n & 1) == 1) sum += 1; n >>= 1; } return sum; } int main() { int N; cin >> N; for (int i = 1; i <... |
#include <bits/stdc++.h> using namespace std; const long long N = 810000; inline long long read() { long long s = 0, w = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) w = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) s = (s << 3) + (s << 1) + (c... |
#include <bits/stdc++.h> using namespace std; namespace chu_xuan { void swap(int &a, int &b) { register int tmp = a; a = b, b = tmp; } void read(long long &a) { a = 0; int b = 1, c = getchar(); while (c > 9 || c < 0 ) { if (c == - ) b = -1; c = getchar(); } while (c... |
#include <bits/stdc++.h> using namespace std; string s; long long fastpow(int b, int e) { if (!e) return 1; if (e & 1) return b * fastpow(b, e - 1); long long temp = fastpow(b, e / 2); return temp * temp; } int notwork(char a, char b) { set<char> s; s.insert(a); s.insert(b); if... |
#include <bits/stdc++.h> using namespace std; struct chess { bool used; int x, y; char p; } up, down, Left, Right, up_Left, up_Right, down_Left, down_Right; int n, kx, ky; void add(int x, int y, char c) { if (x == kx) { if (y < ky) { if (!Left.used || y > Left.y) { Left... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long x; cin >> x; for (long long i = 0; i <= 1000; i++) { for (long long j = 0; j <= 10000; j++) { long long g = i * 1234567 + j * 123456; long l... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2007; const int mod = 1e9 + 7; int n, m; int dp[maxn][maxn][2], block[maxn][maxn][2], sum[maxn][maxn][2], vec[maxn][2]; char s[maxn][maxn]; int calc(int u, int v, int w) { if (w == 0) { for (; vec[v][1] < u; ++vec[v][1]) { if... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; cout << (n - 2) * (n - 2); return 0; } |
#include <bits/stdc++.h> using namespace std; using namespace std; long long k, p; long long getZCY(long long x) { long long res = x; while (x) { res *= 10LL; res += x % 10; x /= 10; } return res; } int main() { scanf( %I64d , &k); scanf( %I64d , &p); long long ... |
#include <bits/stdc++.h> using namespace std; vector<int> neigh[200009]; int ans[200009]; int a[200009]; int b[200009]; int c[200009]; int f[200009]; int Q[200009]; int L, R; int main() { int n, m; scanf( %d %d , &n, &m); for (int i = 0; i < m; i++) { scanf( %d %d %d , &a[i], &b[i]... |
#include <bits/stdc++.h> using namespace std; long long modpow(long long base, long long exp, long long modulus) { base %= modulus; long long result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return resul... |
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <set> #include <cmath> #include <bitset> #include <iomanip> #include <queue> #include <stack> #include <map> #include <unordered_map> #include <unordered_set> #include <chrono> #include <random> #includ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; int n, m; vector<int> a; int main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n >> m; a.resize(n); for (int i = 0; i < n; i++) cin >> a[i]; sort(a.begin(), a.end()); int cnt = ... |
#include <bits/stdc++.h> using namespace std; const int N = 20; int n, k; int dp[1 << N][2][2]; int main() { scanf( %d%d , &n, &k); for (int i = 1; i < (1 << n); ++i) dp[i][0][0] = dp[i][0][1] = dp[i][1][0] = dp[i][1][1] = -1e9; for (int i = 1; i <= k; ++i) { int a; scanf( %d , &... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.