func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N = 7, POWN = (1 << N), MOD = 1000 * 1000 * 1000 + 7; int ans[POWN], res[POWN], a[POWN][POWN], b[POWN][POWN], c[POWN][POWN]; void powm(int p, int n) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { b[i][j] = a[i][j]; a[... |
#include <bits/stdc++.h> using namespace std; int n, m, s, t, g; int dl[200009], head, last, q[20009]; int dep[20010]; int h[20010], top = 1; struct edge { int to, net; long long w; } es[200009]; void add(int u, int v, long long w) { top++; es[top].w = w; es[top].net = h[u]; h[u]... |
#include <bits/stdc++.h> using namespace std; int main() { int r, c, n, mnm, x, y, ret = 0; cin >> r >> c >> n >> mnm; vector<vector<int> > mapa(r, vector<int>(c, 1)); for (int i = 0; i < n; i++) { cin >> x >> y; mapa[x - 1][y - 1] = 2; } for (int i = 1; i <= r; i++) { for ... |
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n; cin >> n; vector<pair<long long, long long> > v(n); for (long long i = 0; i < n; i++) { cin >> v[i].first >> v[i].second; } long long sum = 0; ... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; const long long mod = 1e9 + 7; const long long modd = 1; const long long N = 1e5 + 5; void solve() { long long n, m; cin >> n >> m; long long a[n + 1][m + 1]; for (long long i = 0; i < n; i++) for (long long j = ... |
#include <bits/stdc++.h> int a, b, i, j, n; std::string s; bool isgood(int n) { int i; for (i = 2; i < n; i++) if (n % i == 0) return false; return true; } void sol() { if (!isgood(b)) { printf( NO ); return; } for (i = a + 1; i < b; i++) if (isgood(i)) { ... |
#include <bits/stdc++.h> using namespace std; long long par[200000]; long long ran[200000]; long long cnt[200000]; void init(long long n) { for (long long i = 0; i <= n; i++) { par[i] = i; ran[i] = 0; } } long long finds(long long x) { if (par[x] == x) return x; else ... |
#include <bits/stdc++.h> const int P = 29; using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); ... |
#include <bits/stdc++.h> using namespace std; int x[3]; int y[3]; bool isok(int a, int b, int c) { if (b > c && a > c && a < b) return true; if (b < c && a > b && a < c) return true; return false; } bool TP() { if (x[1] == x[0] && isok(y[2], y[1], y[0])) return true; if (x[2] == x[0] && ... |
#include <bits/stdc++.h> using namespace std; int execute() { int n; cin >> n; string s; s.assign(n / 2 - 1, 1 ); if (n % 2) { cout << 7; } else { cout << 1; } cout << s << endl; return 0; } int TE = true; bool mTest = true; int main() { ios_base::sync_wi... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3 * 100010; const int maxm = 3 * 100010; const int BUFF = 10 * 1010 * 1010; const int block = 400; int n, m; int ans[maxm]; struct DSU { int fa[maxn], rk[maxn]; int *where[BUFF], val[BUFF]; int tot; void init() { tot = ... |
#include <bits/stdc++.h> using namespace std; template <class node> struct link_cut_tree { bool connected(node* u, node* v) { return lca(u, v) != NULL; } int depth(node* u) { access(u); return get_sz(u->ch[0]); } node* get_root(node* u) { access(u); while (u->ch[0]) u = u->... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 5; int n, m; namespace BCC { const int N = 202020; vector<int> bcc[N]; vector<int> k; int cnt, dfn[N], low[N], id[N], st[N], _st, _, to[N]; void dfs(int c, int dep, vector<int> g[]) { int cc = 0; st[_st++] = c; dfn[c] = low[... |
#include <bits/stdc++.h> using namespace std; const int N = 2548; bool g[N][N], c[N][N], v[N][N]; int ng[N][N], sg[N][N], sc[N][N]; int c_square, c_circle, n; template <class T> inline T sqr(T x) { return x * x; } int qx[N * N], qy[N * N], tcnt; inline void solve(int x, int y) { const int dx... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e5 + 4; int main() { int n; cin >> n; int sum[101] = {0}; for (int i = 0, num; i < n; ++i) { cin >> num; sum[i + 1] = sum[i] + num; } if (sum[n] != 0) { cout << YES n1 n ; cout << 1 << n << endl; ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int n, s; cin >> n >> s; long long int a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; long long int x = 1; int i = 1; while (i <= n) { if (a[i] > a[x... |
#include <bits/stdc++.h> int main() { int l, i, flag = 0; char s[50]; scanf( %s , s); l = strlen(s); for (i = 0; i < l; i++) { if (s[0] == s[i]) flag = flag + 1; } if (flag == l) { printf( %d , 0); return 0; } flag = 0; for (i = 0; i < (l / 2); i++) { if... |
#include <bits/stdc++.h> using namespace std; int main() { int flag = 0, i, k; string str, s; cin >> str; if (str.at(0) == - ) { flag = 1; str.erase(0, 1); } if (flag == 1) cout << ( ; cout << $ ; if ((int)str.find( . ) != -1) s = str.substr(0, str.find( . )); ... |
#include <bits/stdc++.h> using namespace std; char str[100400]; int len; long long k; int r, ret; long long calc(int x) { return len - x; } int Q[100400]; char res[100400]; void solve(int x) { int i, j; for (j = 0; j < 26; j++) { long long sum = 0; queue<int> q; for (i = 0; i... |
#include <bits/stdc++.h> using namespace std; const int inf = int(1e9); const double eps = 1e-4; const double pi = 4 * atan(double(1)); const int N = int(3e5) + 100; const int M = int(1e6) + 100; const int sizes[] = {3600, 60, 1, -1}; const int MOD1 = int(1e9) + 7; const int X1 = 4243; struct _hash ... |
#include <bits/stdc++.h> using namespace std; void readn(int &x) { char c; x = 0; do { c = getchar(); } while (c < 0 || c > 9 ); do { x = x * 10 + c - 0 ; c = getchar(); } while (c <= 9 && c >= 0 ); } const int MAXN = 101 * 1000; int k, n, maxb, t, out = 0; i... |
#include <bits/stdc++.h> using namespace std; const int tb[8] = {888888053, 888888047, 888888023, 888887981, 888887977, 888887957, 888887933, 888887911}; char s[2][2005], u[2005]; int n, m, P; long long ans = 0; int f[2][2005][2005]; int h[2][2005], p[2005], q[2005], pw[2005]; int c... |
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long n, k, m, f[100005][15][20]; long long count(long long x) { long long sum = 0; while (x) sum++, x -= (x & -x); return sum; } signed main() { scanf( %lld%lld%lld , &n, &k, &m); f[0][0][0] = 1; for (l... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 700000; int n, g, r; int l[MAXN]; long long sum[MAXN]; long long d[MAXN]; long long cycle; int m; long long q[MAXN], code[MAXN]; int minv[MAXN]; void build(int l, int r, int v) { minv[v] = n + 1; if (l != r) build(l, (l +... |
#include <bits/stdc++.h> using namespace std; class Solver { public: void input() { cin >> n; a.resize(n); for (int i = 0; i < n; i++) { cin >> a[i]; } } void print() { cout << solve() << endl; } private: vector<int> a; int n; long long f(int x) { ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-6; const double PI = 3.14159265358979323846264338f; const double pi = acos(-1.0); const int inf = 0x3f3f3f3f; const long long mod = 1e9 + 7; const int MAXN = 1005; inline int read() { int c = 0, f = 1; char ch = getchar(); w... |
#include <bits/stdc++.h> using namespace std; int main() { int l = 0, r = 0; string s, t; cin >> s >> t; int i = 0; for (int j = 0; j < t.length(); j++) { if (s[i] == t[j]) { if (i == s.length() - 1) { i = s.length() - 1; l = j + 1; break; } el... |
#include <bits/stdc++.h> using namespace std; bool isLeaf[100001] = {0}; bool isCorrect[100001] = {0}; bool nowCorrect[100001] = {0}; bool allVisited[100001] = {0}; bool visited = false; vector<int> solution; vector<vector<int> > old_pony_ville, pony_ville; bool dfs(int nodo) { if (!isLeaf[nodo]) ... |
#include <bits/stdc++.h> using namespace std; const long long INFLL = 2 * (long long)1e18 + 100; const long long INFINT = 2 * (long long)1e9 + 100; const double PI = atan(1) * 4; const double EPS = 1e-6; const long long SEED = (long long)1e3 + 7; const long long MOD = 998244353; const long long NMAX = (... |
#include <bits/stdc++.h> using namespace std; void positionInFraction(); int main() { positionInFraction(); return 0; } void positionInFraction() { int b, c, rpta, division; long long a, posicion; cin >> a >> b >> c; bool hayRpta = false; posicion = 1; while (posicion < 100000 ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-5; template <typename T> void cmin(T &x, const T &y) { if (y < x) x = y; } template <typename T> void cmax(T &x, const T &y) { if (y > x) x = y; } template <typename T> void read(T &x) { x = 0; char c = getchar(); ... |
#include <bits/stdc++.h> using namespace std; const int M = 1600; int dr[] = {-1, 0, 1, 0}, dc[] = {0, 1, 0, -1}; int n, m, pr[M][M], pc[M][M]; char g[M][M], f[M][M]; bool dfs(int r, int c) { int u = (r % n + n) % n, v = (c % m + m) % m; if ( # == g[u][v]) return 0; if (f[u][v]) return r != pr[... |
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; if (k % 2 != 0) { cout << -1 ; return 0; } for (int i = 0; i < k; i++) { for (int j = 0; j < k; j++) { for (int t = 0; t < k; t++) { if (i % 2 == 0) { if ((j % 4 <= 1 && t... |
#include <bits/stdc++.h> using namespace std; string i2s(int x) { stringstream ss; ss << x; return ss.str(); } int s2i(string str) { istringstream ss(str); int nro; ss >> nro; return nro; } int n; int NRO5(int nro) { int cnt = 0; while (nro % 5 == 0) { cnt++; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long int n; long long int t[2 * N]; int main() { long long int n, k; cin >> n >> k; long long int a[k], ans = 1e18, g = 0; for (int i = 0; i < k; i++) { cin >> a[i]; if (n % a[i] < ans) { ans = n % a[i]; ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 10; int n; set<pair<pair<int, int>, int> > a; int ans[MAXN]; inline pair<pair<int, int>, int> mpi(int a, int b, int c) { return make_pair(make_pair(a, b), c); } void exit() { cout << Impossible ; exit(0); } int main() ... |
#include <bits/stdc++.h> using namespace std; const double pp = 0.00000001; const int maxn = 100005; double ans, xo, da, mid; int ci, w, i, n, x[maxn], y[maxn]; bool pd(double k) { double ww, l = -1e9, r = 1e9; int i; for (i = 1; i <= n; i++) { if (k * k < (y[i] - k) * (y[i] - k)) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int64_t t, a[200005], n; cin >> t; while (t--) { int64_t dem = 1; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); for (int i = 1; i < n; i++) { if (a[i] != a[i + 1]) dem++; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s = ; cin >> s; int y = 0; while (s[y] == a && y <= s.length()) ++y; for (int i = y; i < s.length(); ++i) { if (s[i] == a ) break; else --s[i]; } if (y == s.length()) s[s.length() - 1] = z... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long int n; cin >> n; long long int a[n], b[n]; long long int sum_1 = 0, sum_2 = 0, c = 0; for (long long int i = 0; i <= n - 1; i++) { cin >> a[i] >> b[i]... |
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int f[210000 * 4], mn[210000 * 4]; void add(int u, int L, int R, int l, int r, int k) { l = max(l, L); r = min(r, R); if (l >= r) return; if (l == L && R == r) { mn[u] += k; f[u] += k; return; } add(u * 2, ... |
#include <bits/stdc++.h> using namespace std; const int inf = 2e9; const long long Inf = 1e10; const int N = 500005; const double pi = acos(-1); inline int IN() { int x = 0; int ch = 0, f = 0; for (ch = getchar(); ch != -1 && (ch < 48 || ch > 57); ch = getchar()) f = (ch == - ); for (... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5e5 + 5; const int inf = 1e9 + 5e5 + 19; int n, k; int a[maxn]; bool in_b[maxn]; struct fenwick { int n; vector<int> val; void init(int _n) { n = _n; val.assign(n + 5, -1); } void update(int x, int k) { fo... |
#include <bits/stdc++.h> using namespace std; int prime[500000]; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } int main() { long long n; cin >> n; long long x = n; for (long long i = 2; i * i <= n; i++) if (n % i == 0) { x = gcd(x... |
#include <bits/stdc++.h> using namespace std; int ts, kk = 1; template <class T> inline T _sq(T a) { return a * a; } template <class T, class X> inline T _pow(T a, X y) { T z = 1; for (int i = 1; i <= y; i++) { z *= a; } return z; } template <class T> inline T _gcd(T a, T b... |
#include <bits/stdc++.h> int n; char s[11]; int main() { scanf( %d , &n); int pos = 20000; for (int i = 1; i <= n; i++) { int num; scanf( %d%s , &num, s + 1); if (s[1] == N ) { if (pos + num > 20000) { puts( NO ); return 0; } else pos +=... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<long long, long long> a, pair<long long, long long> b) { if (a.first != b.first) { return a.first < b.first; } return a.second > b.second; } const int maxn = (int)1e7; struct vt { int ed[2]; bool term; vt() { ed[0]... |
#include <bits/stdc++.h> int a[100010], b[100010]; bool check(int *a, int n, int id) { int cntt = 0; for (int i = 0; i < n; i++) { if (i == id) continue; b[cntt++] = a[i]; } if (cntt == 1) return true; for (int i = 1; i < cntt; i++) if (b[i - 1] == 0 && b[i] != 0) return false;... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k, i, j; long long int flag = 0; cin >> n >> k; long long int m = n * n; long long int p; char a[1000][1000]; if (m % 2 == 0) { p = m / 2; } else { p = (m + 1) / 2; } if (k > p) { co... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int ans = ((n - 1) * n * (n + 1)) / 3 - 2; cout << ans; return 0; } |
#include <bits/stdc++.h> const int MN = 2e2 + 10; template <typename T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <typename T> bool ckmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; } template <typename F, int MN, int MM> struct MaxFlow { public: int hd... |
#include <bits/stdc++.h> using namespace std; void solve() { long long n, x; cin >> n >> x; long long a[n]; for (auto &i : a) cin >> i; long long pre[n + 1]; pre[0] = 0; for (long long i = 1; i <= n; i++) pre[i] = (pre[i - 1] + a[i - 1]) % x; long long ans = 0; for (long long i =... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; const int SINF = 0x7fffffff; const long long LINF = 0x3fffffffffffffff; const long long SLINF = 0x7fffffffffffffff; const long double DINF = pow(2, 100); const int MAXN = 100007; const long double EPS = 1e-17; const long double ... |
#include <bits/stdc++.h> using namespace std; class segmentTree { public: int* tree; int N; int size; void update(int qidx, int val) { update(qidx, val, 0, N - 1, 0); } void update(int qidx, int val, int left, int right, int idx) { if (left == right && left == qidx) { tree[idx] ... |
#include <bits/stdc++.h> using namespace std; const int N = 200010; char s[N]; vector<int> v[N]; set<int> s1, s2; set<int>::iterator j; inline int gi() { int x = 0, o = 1; char ch = getchar(); while (ch != - && (ch < 0 || ch > 9 )) ch = getchar(); if (ch == - ) o = -1, ch = getchar()... |
#include <bits/stdc++.h> using namespace std; const int maxn = 5 * 1000000 + 100; char str[maxn << 1], s[maxn]; int p[maxn << 1]; int ans; int n; int f[maxn << 1]; void Init(void) { str[0] = $ , str[1] = # ; for (int i = 0; i < n; i++) { str[i * 2 + 2] = s[i]; str[i * 2 + 3] = # ;... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while (ch >= 0 && ch <= 9 ) { x = x * 10 + ch - 0 ; ch = getchar(); } return x * f;... |
#include <bits/stdc++.h> using namespace std; int a[100005]; int t[400005]; int d[400005]; pair<int, int> p[305]; pair<int, int> cp[305]; int n; void build(int l, int r, int i) { d[i] = 0; if (l == r) t[i] = a[l]; else { int m = (l + r) / 2; int L = 2 * i; build(l, m,... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; vector<vector<pair<long long, long long>>> adj; vector<long long> dist; vector<bool> visited; void djikstra(long long src) { priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, grea... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; y--; if ((y > x) || y == -1 || (x - y) % 2 != 0 || (!y && x)) cout << NO ; else cout << YES ; return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<string> a; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } for (int i = n - 1; i >= 0; i--) { if (a.count(s[i]) == 0) { cout << s[i] << endl; a.insert(s[i]); ... |
#include <bits/stdc++.h> using namespace std; const int Z = (int)1e5 + 111; const int INF = (int)1e9 * 2 + 111; int n, m, k; bool can(long long x) { int u = k; int one = x, two = max(x - k + 1, (long long)1); long long p = ((long long)one + two) * ((long long)one - two + 1) / 2; p += (long lon... |
#include <bits/stdc++.h> const int Maxn = 1000 * 1000 + 10; using namespace std; int main() { vector<int> A[10000]; int B[10000]; int n; cin >> n; n *= 2; int e[10000]; for (int i = 0; i < n; i++) { int a; cin >> a; A[a].push_back(i); B[i] = a; } bool k ... |
#include <bits/stdc++.h> using namespace std; const int N = 5001; int n, k, a[N * 60]; long long dp[N][N]; int main() { scanf( %d%d , &n, &k); for (int i = 0; i < n; i++) scanf( %d , a + i); sort(a, a + n); for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) dp[i][j] = 5e18; dp[k... |
#include <bits/stdc++.h> using namespace std; int main() { int n, s, a[1000]; int max = 0; scanf( %d%d , &n, &s); int sum = 0; for (int i = 0; i < n; i++) { scanf( %d , &a[i]); if (a[i] > max) max = a[i]; } int flag = 1; for (int i = 0; i < n; i++) { if (a[i] == max... |
#include <bits/stdc++.h> using namespace std; int pos[200003]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, x, l = 0, r = 0; char c; cin >> n; cin >> c >> x; n--; while (n--) { cin >> c >> x; if (c == L ) { pos[x] = -... |
#include <bits/stdc++.h> using namespace std; int l[7]; int main() { scanf( %d%d%d , &l[3], &l[4], &l[5]); double a, A, ap, r, anw = 0; for (int n = 3; n <= 5; n++) { a = acos(-1) / n; A = 1.0 * n / 4 * l[n] * l[n] / tan(a); ap = A * 2 / n / l[n]; r = ap / cos(a); anw += ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(NULL); int tc; cin >> tc; while (tc--) { int n; cin >> n; int sum = (n % 10 - 1) * 10; if (1 <= n) sum += 1; if (10 <= n) sum += 2; if (100 <= n) sum += 3; if (10... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353, N = 510; int n, m, a[N], st[N][12], g[N][12], dp[N][N]; int solve(int l, int r) { if (dp[l][r]) return dp[l][r]; if (l > r) return 1; long long r1 = 0, r2 = 0; int pos, lo = log2(r - l + 1); if (st[l][lo] < st[r - (1 <<... |
#include <bits/stdc++.h> using namespace std; const int N = 2e6 + 7; int cnt[N], a[N], idx, l, r, n; long long ans, sum; int main() { scanf( %d , &n); for (int i = (1); i <= (n); ++i) { scanf( %d , a + i); if (a[i] >= i) l++, cnt[a[i] - i]++; else r++; ans += ab... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; vector<long long> presum(maxn, 0); int main() { int last = 0; for (long long i = 1; i < maxn; ++i) { presum[i] = presum[i - 1] + min(i, 9LL); if (i >= 10 && i < 100) { presum[i] = presum[i] + (2LL * (i - 9LL)); ... |
#include <bits/stdc++.h> #pragma comment(linker, /stack:200000000 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) #pragma GCC optimize( unroll-loops ) using namespace std; template <class T> inline T bigmod(T p, T e, T M) { long long ret =... |
#include <bits/stdc++.h> using namespace std; int len, cnt[8010], f[8010], nxt[8010]; char st[8010]; void kmp(char *st, int len, int nxt[]) { nxt[0] = nxt[1] = 0; for (int i = 1; i < len; i++) { int j = nxt[i]; while (j && st[i] != st[j]) { j = nxt[j]; } nxt[i + 1] = st[j... |
#include <bits/stdc++.h> using namespace std; struct query { int Q, id; long long res; }; const int Nmax = 200001; int n, m, parent[Nmax], Rank[Nmax]; vector<pair<int, pair<int, int> > > edge; bool cmpQ(const query &q1, const query &q2) { return q1.Q < q2.Q; } bool ret(const query &q1, const que... |
#include <bits/stdc++.h> using namespace std; int main() { string s1, s2, s; int cnt, i; while (cin >> s1 >> s2) { sort(s1.begin(), s1.end()); for (s.clear(), cnt = i = 0; i < s1.size() && s1[i] == 0 ; ++cnt, ++i) ; if (i < s1.size()) s += s1[i++]; while (cnt--) s += 0 ... |
#include <bits/stdc++.h> using namespace std; int sol[] = {19, 873, 834, 665}; int main() { int a, b; bool found = false; cin >> a >> b; for (int i = 0; i < (int)sizeof(sol) / (int)sizeof(int); i++) { found = true; break; } if (found) cout << a + b << endl; else ... |
#include <bits/stdc++.h> using namespace std; int main() { long long x, y; cin >> x >> y; cout << (x + x % 2) * (y + y % 2) * (x / 2) / 2 * (y / 2) / 2; } |
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000000000000003; long long powmod(long long a, long long b) { long long res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } const int N = 601000; int n... |
#include <bits/stdc++.h> using namespace std; int main() { int m, n; cin >> n >> m; int flag = 0, j, i; for (i = n + 1; i <= m; i++) { flag = 0; for (j = 2; j * j <= i; j++) { if (i % j == 0) { flag = 1; break; } } if (flag == 0) { ... |
#include <bits/stdc++.h> using namespace std; int32_t main() { long long n, k; cin >> n >> k; string s[n - k + 1]; for (long long i = 0; i <= n - k; i++) cin >> s[i]; string c[50]; long long i1 = 65; for (long long i = 0; i < 26; i++) { c[i] = i1; i1++; } i1 = 65; ... |
#include <bits/stdc++.h> using namespace std; int a[1000010]; long long cnt[1000010]; int main() { ios::sync_with_stdio(0); int n; cin >> n; long long s = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; s += a[i]; } if (s % 3 != 0) cout << 0 n ; else { s /=... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= n; i++) { if (i % 4 == 1 or i % 4 == 3) { for (int j = 0; j < m; j++) { cout << # ; } cout << n ; } else if (i % 4 == 2) { for (int k = 0; k <... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (!b) return a; return gcd(b, a % b); } long long fpow(long long a, long long b, long long mod) { long long res = 1ll; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>... |
#include <bits/stdc++.h> using namespace std; char a[100005], ans[100005]; int main() { int n, m; cin >> n; while (n--) { cin >> a; m = strlen(a); for (int i = 0; i < m; i++) { if (a[i] != ? ) { if (ans[i] == 0) ans[i] = a[i]; else if (a[i] !=... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l, minc, maxc; string s; cin >> n; map<int, int> dict; for (int i = 0; i < n; i++) { cin >> s; l = s.length(); if (l == 1) { cout << YES << n ; continue; } for (int j ... |
#include <bits/stdc++.h> using namespace std; double x[150], y[150], z[150], a = 0, b = 0, c = 0; double dist(double x, double y, double z) { return x * x + y * y + z * z; } int main() { int i, n, ij, j; double bit = 1, t, temp; cin >> n; for (i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i]; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, t; cin >> s; cin >> t; long int n, m, sum; n = s.size(); m = t.size(); long int count = 0; if (s.size() == 0 && t.size() == 0) { cout << 0; } else if (s.size() == 0 && t.size() != 0) { cout << t.size... |
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, ch; while (!isdigit(ch = getchar())) ; while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return x; } const int MAXN = 500000; const int mod = 1000000007; int n; int a[MAXN + 1]; int ... |
#include <bits/stdc++.h> using namespace std; const int m = 31623; int nim[] = { 0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12, }; bool isLarge[m]; int n; int main(void) { cin >> n; memset(isLarge, true, sizeof(isLarge)); for (int i =... |
#include <bits/stdc++.h> using namespace std; long long f[505][505]; int main() { int n, k; scanf( %d%d , &n, &k); for (int i = 0; i <= n; i++) f[0][i] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 0; k < j; k++) { (f[j][i] += f[k][i - 1] *... |
#include <bits/stdc++.h> using namespace std; const int INF = 1000000000; int n; int x[300010]; int y[300010]; pair<int, int> izq, der, down, up; int ereccion(int i, int j, int k) { vector<int> pito, ura; pito.push_back(x[i]); pito.push_back(x[j]); pito.push_back(x[k]); ura.push_back(y... |
#include <bits/stdc++.h> using namespace std; int solve() { long long n; cin >> n; vector<long long int> a, b; long long x; for (long long int i = 0; i < n; i++) { cin >> x; if (x > 0) a.push_back(x); else b.push_back(x); } long long sum1 = accumulate(a.... |
#include <bits/stdc++.h> using namespace std; const int sigma_size = 26; const int N = 100 + 50; const int MAXN = 100000 + 50; const int inf = 0x3fffffff; const double eps = 1e-8; const int mod = 1000000000 + 7; int n, k; int a[N]; double dp[N][N], res[N][N]; int main() { while (~scanf( %d%d ,... |
#include <bits/stdc++.h> using namespace std; int n, m, a[5001], i, j, b[5001], ans; int main() { scanf( %d%d , &n, &m); for (i = 1; i <= n; i++) { scanf( %d , &a[i]); b[i] = a[i]; } for (i = 1; i <= n; i++) if (a[i] == b[i]) for (j = 1; j <= n; j++) if (a[i] !=... |
#include <bits/stdc++.h> using namespace std; long long a[200001], b[200001], c[200001], d[200001], s, n, cnt[200001]; int bit(int a, int j) { return (a & (1 << j)) >> j; } int checkb() { int mb = 0; for (int i = 1; i <= n; ++i) { for (int j = 0; j <= 29; ++j) { int x = bit(a[i], j), y = b... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( Ofast ) #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native ) using namespace std; long long int t, l, r, m[200005][26]; string second; int32_t main() { ios_base::sync_with_stdio(); cin.tie(); cou... |
#include <bits/stdc++.h> using namespace std; /*<DEBUG>*/ #define tem template <typename #define can_shift(_X_, ...) enable_if_t<sizeof test<_X_>(0) __VA_ARGS__ 8, debug&> operator<<(T i) #define _op debug& operator<< tem C > auto test(C *x) -> decltype(cerr << *x, 0LL); tem C > char test(...); tem ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; map<string, int> m; int groot = 0; string p = ; vector<string> vec; for (int i = 1; i < s.size(); i++) { p.push_back(s[i - 1]); p.push_back(s[i]); m[p]++; gro... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 2) cout << -1; else { cout << 15 << endl << 10 << endl << 6 << endl; for (int i = 2; i <= n - 2; ++i) cout << 15 * i << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; struct A { int fr, to, th; long long d; A() {} A(int a, int b, long long c, int d) : fr(a), to(b), d(c), th(d) {} }; const int N = 1003; vector<A> edge, G[N], ze, all, ori; int from[N]; long long dis[N]; void SPFA(int x) { queue<int> q; ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.