func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> struct point { double x, y; } p, q, u; double v, vp, r, R, k; double po, qo, pa, qa, angp, angq, angpq; point rorate(point a, double ang) { point c; c.x = a.x * cos(ang) - a.y * sin(ang); c.y = a.x * sin(ang) + a.y * cos(ang); return c; } double disp2o(point a)... |
#include <bits/stdc++.h> using namespace std; long long n, m; void in() { cin >> n >> m; } void out() { int s = 0; if (n > m) { cout << n - m; return; } while (n < m) { s++; n <<= 1; } int diff = n - m; n >>= 1; long long x = 2; long long c = 0; wh... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 5; const int K = 20; vector<int> P[N]; int s[K]; int t[K]; int L[1 << K]; int R[1 << K]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n, m, k; cin >> n >> m >> k; char f; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 123, INF = 1e9, mod = 1e9 + 7, N = 2e5 + 123; struct btr { map<int, long long> dp; set<pair<long long, int> > st; long long mn, add; }; vector<int> g[maxn]; int n, m; btr a[maxn]; void Merge(btr &a, btr &b) { if (a.dp.s... |
#include <bits/stdc++.h> using namespace std; template <typename T> void read(T &x) { x = 0; char ch = getchar(); int f = 1; while (!isdigit(ch)) { if (ch == - ) f *= -1; ch = getchar(); }; while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); } x *= ... |
#include <bits/stdc++.h> int n; double p; double C2(double x) { if (x < 1) return 0; return x * (x - 1) / 2; } double C3(double x) { if (x < 2) return 0; return x * (x - 1) * (x - 2) / 6; } int main() { std::cin >> n >> p; for (int i = 0; i <= n; i++) if ([&](int x) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, st, ed, i, j, ep = 1, h[1005]; long long d[1005][1005], dis[1005]; queue<int> q; struct node { int y, ne, v; } e[1000005]; void add(int a, int b, int v) { e[ep].y = b; e[ep].v = v; e[ep].ne = h[a]; h[a] = ep; ep++; } int m... |
#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 main() { int r, d; cin >> r >> d; int n; cin >> n; d = r - d; int ans = 0; for (int i = 0; i < n; i++) { int x, y, rx; cin >> x >> y >> rx; long double distance = sqrt(x * x + y * y); long double temp = (rx); ... |
#include <bits/stdc++.h> using namespace std; using lint = long long int; lint liters(int l, vector<int> &arr) { lint sum = 0; for (int k : arr) sum += (lint)(k - l); return sum; } int main() { int n, m = 1000000010; lint s; vector<int> arr; cin >> n >> s; arr.resize(n); fo... |
#include <bits/stdc++.h> using namespace std; struct node { int val, lazy, child; node() { val = child = 0; lazy = 1e9 + 7; } node(int vval, int llazy, int cchild) { val = vval; lazy = llazy; child = cchild; } }; int N, K, Q; int w, x, y, z; int arr[100100];... |
#include <bits/stdc++.h> using namespace std; long long bin_pow(long long a, long long b) { if (b == 0) return 1; if (b % 2 == 0) { long long t = bin_pow(a, b / 2); return t * t % 1000000007; } else return a * bin_pow(a, b - 1) % 1000000007; } long long t = 1, n, m, k = 0, sum = 0,... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 1; int n, x[N]; char c[N]; vector<pair<int, int>> segs; long long ans; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; int last = -1; for (int i = 0; i < n; i++) { cin >> x[i] >> c[i]; if (c[i... |
#include <bits/stdc++.h> using namespace std; const int N = 3000000 + 7; const int M = 1500 + 7; const int inf = 1e9 + 7; const long long linf = 1ll * inf * (inf - 1); const double pi = acos(-1); const double eps = 1e-6; const bool multipleTest = false; const int mod[2] = {inf, 984723593 + 7}; const... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:512000000 ) using namespace std; void solve(); void precalc(); clock_t start; int testNumber = 1; bool todo = true; int main() { start = clock(); int t = 1; cout.sync_with_stdio(0); cin.tie(0); precalc(); cout.precision(10)... |
#include <bits/stdc++.h> using namespace std; const long double eps = 1e-10; const int maxn = 1000 * 1000 * 1000 + 2; int n; int a[3][5 * 100 * 1000 + 2]; long double s, e = maxn; bool check(long double x) { long double maxr = -1000000001; for (int i = 0; i < n; i++) { if (a[2][i] > 0 && ... |
#include <bits/stdc++.h> using namespace std; const int M = 1000001; int n, m, k, a[M], ver[M], nex[M], head[M], cnt, fa[M], dp[M], tmp[M], sz[M]; vector<int> v[M]; long long d[M]; void add(int x, int y) { ver[++cnt] = y, nex[cnt] = head[x], head[x] = cnt; ver[++cnt] = x, nex[cnt] = head[y], head[y]... |
#include <bits/stdc++.h> using namespace std; void fre() { freopen( c://test//input.in , r , stdin); freopen( c://test//output.out , w , stdout); } template <class T> inline void gmax(T &a, T b) { if (b > a) a = b; } template <class T> inline void gmin(T &a, T b) { if (b < a) a = b; ... |
#include <bits/stdc++.h> using namespace std; using namespace std::chrono; const int MAXN = 100500; bool is_occupied[MAXN]; string names[MAXN]; int types[MAXN]; vector<string> nonex_bad; vector<string> ex_bad; vector<string> ex_neutral, nonex_neutral; bool is_bogus_name(string const& fname) { if... |
#include <bits/stdc++.h> using namespace std; namespace my_useful_tools { const int INF = 0x3f3f3f3f; inline void pc(char c) { putchar(c); } template <class T> inline T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <class T> inline void W(T p) { if (p < 0) pc( - ), p = -p; ... |
#include <bits/stdc++.h> using namespace std; int i, j, n, c, d; string a[105], b[105]; int main() { for (cin >> n; i++ < n; d += !c) for (cin >> a[i] >> b[i], j = c = 0; ++j < i;) c += a[i] == a[j] & b[i] == b[j]; cout << d; return 0; } |
#include <bits/stdc++.h> using namespace std; const int mod = 998244853; int n, m; long long dp[2005][2005], k[2005][2005], C[4005][4005]; void init() { for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (i == 0) k[i][j] = 1; else if (j == 0) k[i][j]... |
/* * @Descripttion: * @version: * @Author: 纸月二五 * @Date: 2021-05-11 17:50:44 */ #include<bits/stdc++.h> using namespace std; int num[200010]; long long cal(long long m) { return m * (m - 1) / 2; } int main() { int T; scanf( %d ,&T); while(T --) ... |
#include <bits/stdc++.h> using namespace std; int k, s, luu; int F[100000]; int a[100000]; int res; int main() { cin >> s >> k; F[0] = 1; F[1] = 1; for (int i = 2; i <= 10000; i++) { F[i] = 2 * F[i - 1]; if (i >= k + 1) F[i] -= F[i - k - 1]; if (F[i] > 1000000000) { ... |
#include <bits/stdc++.h> using namespace std; const int cmax = 223466; int p[cmax]; set<int> s; int n, q; int find(int x) { return p[x] == x ? x : p[x] = find(p[x]); } void merge(int x, int y) { int xx = find(x); int yy = find(y); if (xx == yy) return; if (rand() % 2) swap(xx, yy); p[x... |
#include <bits/stdc++.h> using namespace std; int main() { int a, ta, b, i, j, tb, h, m, t; int d, ar; char ch[10]; cin >> a >> ta >> b >> tb; cin >> ch; h = (ch[0] - 0 ) * 10 + ch[1] - 0 ; m = (ch[3] - 0 ) * 10 + ch[4] - 0 ; t = (h - 5) * 60 + m; j = 0; long long count =... |
#include <bits/stdc++.h> using namespace std; const int N = 16505; const int inf = 1e9 + 7; char s[N]; int fa[N * 2], rk[N * 2]; bool c[N], p[N]; inline int C(char q) { if (q <= 9 ) return q - 0 ; else return q - A + 10; } int tot; inline int find(int x) { return x == fa[x] ?... |
#include <bits/stdc++.h> using namespace std; const int MAX = 1e3 + 55; int x[MAX]; int s[2]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> x[i]; int i = 0; int l = 0, r = n - 1; while (l <= r) { if (x[l] > x[r]) { s[i % 2] += x[l]; l++; }... |
#include <bits/stdc++.h> using namespace std; int a[1111111]; int main() { ios_base::sync_with_stdio(false); int n; long long ts, tf, t; cin >> ts >> tf >> t; cin >> n; long long ansV = ts, ans = 0; long long total = ts; for (int i = 0; i <= n; i++) { long long x; if (i... |
#include <bits/stdc++.h> using namespace std; void c_p_c() {} void solution() { int a, b, c; cin >> a >> b >> c; cout << min(a, min(b / 2, c / 4)) * 7 << endl; } int32_t main() { c_p_c(); ios_base::sync_with_stdio(false); cin.tie(NULL); ; solution(); return 0; } |
#include <bits/stdc++.h> using namespace std; int tree[262192]; int a[262192], pre[262192], ok[262192]; int n; void check() { int i, all_1 = 1; for (i = 1; i <= n; ++i) { if (a[i] != 1) all_1 = 0; } if (all_1) { printf( 1 n ); exit(0); } } void update(int pt, int l, i... |
#include <bits/stdc++.h> inline long long ceil_div(long long a, long long b) { return (a + b - 1) / b; } using namespace std; inline int qr() { int f = 0, fu = 1; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) fu = -1; c = getchar(); } while (c >= 0 && c <= 9 ) {... |
#include <bits/stdc++.h> const int N = 1e3 + 10, O = 27; int cnt, n, m; bool v[O], ok[O], cur[O]; std::vector<int> empty, full; std::string s, temp; int main() { scanf( %d , &n); std::cin >> s; for (int i = 0; i < n; i++) { if (s[i] != * ) { v[s[i] - a ] = true; full.push... |
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const double pi = acos(-1.0); int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, -1, 1, 1, -1}; struct point_i { int x, y; point_i() { x = y = 0; }; point_i(int x_, int y_) : x(x_), y(y_) {} }; struct line {... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); mt19937_64 rngll(rng()); const int mn = 1e6 + 10; const long long mod = 1e9 + 7; long long fact[mn]; long long po(long long a, long long b = mod - 2) { if (b < 0) b += mod - 1; long l... |
#include <bits/stdc++.h> using namespace std; struct P { long long x; long long y; bool operator<(const P &a) const { return y > a.y; } }; vector<long long> v[3]; int a, c, i, b, n, m, k, d; long long o[1333331]; int l[1111111]; int j[1111115]; int e[1111111]; int dx[10] = {0, 1, 0, -1, ... |
#include <bits/stdc++.h> using namespace std; char moves[4] = { L , U , R , D }; long long dx[4] = {-1, 0, 1, 0}; long long dy[4] = {0, -1, 0, 1}; const long long N = 1e3 + 1; bool visited[N]; vector<long long> adj[N]; long long n, k; signed main() { ios_base::sync_with_stdio(0); cin.tie(0)... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; struct Node { int cnt, l, r, z_0, z_1; Node() { cnt = 0; l = r = -1; z_0 = z_1 = 0; } }; vector<Node> Trie; void update(int x) { int cur = 0; for (int i = 30; i >= 0; i--) { int c = (((1 << i) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; int l = s.length(); int f[l + 2]; int a[26] = {0}; int l1[1000005], l2[1000005]; for (int i = 0; i <= l; i++) { f[i] = 0, l1[i] = 0, l2[i] = 0; } for (int i = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { long int i, k, j, l, a, b, len; scanf( %ld%ld , &len, &k); if (k > len) { printf( -1 n ); return 0; } if ((len > 1) && (k == 1)) { printf( -1 n ); return 0; } if ((len == 1) && (k == 1)) { printf( a ... |
#include <bits/stdc++.h> using namespace std; char s[100005]; int main(void) { int n, a, b; scanf( %d%d%d%s , &n, &a, &b, s); --a; --b; puts(s[a] != s[b] ? 1 : 0 ); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); ; int precision = numeric_limits<double>::digits10; ; int n; cin >> n; int j = sqrt(n), k = sqrt(n); for (int i = j; i > 0; i--) { for (int p = k; p < n + 1; p++) { if (i * p == n) ... |
#include <bits/stdc++.h> const long long MOD = 1e9 + 7; using pii = std::pair<long long, long long>; using namespace std; long long n; string s; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> s; long long good = 1; for (long long i = 0; i < n; i++) for (... |
#include <bits/stdc++.h> using namespace std; const int N = 50005; int n; int id[N]; vector<pair<int, int> > val; vector<int> sol; int main() { ios ::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { cin >> id[i]; } id[n] = id[0]; for (int i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; int ch[3000005][2]; int v[3000005]; map<int, int> mp; int sz; void inser(int x) { int u = 0; for (int i = 20; i >= 0; i--) { int c = x >> i & 1; if (!ch[u][c]) { memset(ch[sz], 0, sizeof(ch[sz])); v[sz] = 0; ch[u][c] =... |
#include <bits/stdc++.h> const int N = 205; int n, m, A[N][N], a[N][N], h[N], l[N]; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf( %d , &A[i][j]); for (int i = 0; i <= m; i++) { int f = 1; memcpy(a, A, sizeof(A)); memset(h, ... |
#include <bits/stdc++.h> using namespace std; const long maxn = 60; const char spec1[5] = { T , J , Q , K , A }; const char spec2[4] = { S , D , H , C }; long start[maxn]; bool pos[maxn][maxn][maxn][maxn]; long n; bool ispair[maxn][maxn]; int main() { scanf( %ld , &n); long q; long ... |
#include <bits/stdc++.h> using namespace std; const int N = 5005; template <class I> inline void ckMax(I& p, I q) { p = (p > q ? p : q); } template <class I> inline void ckMin(I& p, I q) { p = (p < q ? p : q); } template <class I> inline I Max(I& p, I q) { return p > q ? p : q; } tem... |
#include <bits/stdc++.h> using namespace std; int matrix[505][505]; int m, n; int col[505]; int row[505]; int prime[110000]; int pc; bool visit[110000]; void init() { for (int i = 2; i < 110000; i++) { if (visit[i]) continue; for (int j = i * 2; j < 110000; j += i) visit[j] = true; ... |
#include <bits/stdc++.h> using namespace std; const int N = 1010; const double eps = 1e-9; const double pi = acos(-1.0); int Sng(double x) { if (x < -eps) return -1; if (x > eps) return 1; return 0; } class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) ... |
#include <bits/stdc++.h> using namespace std; template <class _T> inline _T sqr(const _T &first) { return first * first; } template <class _T> inline string tostr(const _T &a) { ostringstream os( ); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795L; ... |
#include <bits/stdc++.h> struct el { int x, y, z; }; using namespace std; int cmp(el a, el b) { return a.x < b.x; } int cmp1(el a, el b) { return a.y < b.y; } int main(int argc, const char* argv[]) { int n, w; cin >> n >> w; vector<el> a; el b; int ans = 0; for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(); int n; cin >> n; vector<pair<int, int> > arr[1001]; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; arr[x / 1000].push_back(make_pair(y, i)); } for (int i = 0... |
#include <bits/stdc++.h> #pragma GCC optimize( O2 ) #pragma GCC optimize( unroll-loops ) using namespace std; const long double eps = 1e-7; const int inf = 1000000010; const long long INF = 10000000000000010LL; const int mod = 1000000007; const int MAXN = 200010, LOG = 20; struct DSU { int par[MAX... |
#include <bits/stdc++.h> using namespace std; int dat[1500][1500], vst[1500][1500], lx[1500][1500], ly[1500][1500], step[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; char str[1600]; int n, m, sx, sy; bool dfs(int x, int y) { int nx = ((x % n) + n) % n; int ny = ((y % m) + m) % m; if (!dat[nx]... |
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const long long int mod = 1e9 + 7; long double dp[111][11111], ans; long long int a[111], n, k, x; int main(void) { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; i... |
#include <bits/stdc++.h> using namespace std; const long long maxN = 3e1 + 17, N = 5e1 + 17, inf = 1e9 + 7, MOD = 1e9 + 7, Mod = 1e9 + 6; long long n, m, y, t, d[maxN][maxN][N], help, mini, x; int main() { for (long long i = 0; i <= 30; i++) { for (long long j = 0; j <= 30; j++) { ... |
#include <bits/stdc++.h> using namespace std; template <typename t> void read(t &x) { char ch = getchar(); x = 0; t f = 1; while (ch < 0 || ch > 9 ) f = (ch == - ? -1 : f), ch = getchar(); while (ch >= 0 && ch <= 9 ) x = x * 10 + ch - 0 , ch = getchar(); x *= f; } long long dp... |
#include <bits/stdc++.h> using namespace std; const int N = 300010; int w[N]; vector<pair<int, int> > v[N], g[N]; int a[N]; int rnk(int x) { while (a[x] != x) a[x] = a[a[x]], x = a[x]; return x; } struct eg { int x, y, id; } e[N]; bool cmp(eg a, eg b) { return w[a.id] < w[b.id]; } bool... |
#include <bits/stdc++.h> using namespace std; const int MX = 1e5 + 6; int n, t[MX]; int ID(int x, int jump) { int st = 1, en = x, ret = 1e6; while (st <= en) { int mid = (st + en) / 2; if (t[x] - jump <= t[mid]) { ret = min(ret, mid); en = mid - 1; } else st = m... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n, m, x1, y1, x2, y2, count = 0; cin >> n >> m; vector<char> v[n]; for (long long int i = 0; i < n; i++) { for (long long int j = 0; j < m; j++) { char x; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long n = s.size(); for (long long i = 0; i < n; i++) { if (s[i] == r ) { cout << i + 1 << n ; } } for (long long i = n - 1; i >= 0; i--) { if (s[i] == l ) { cout << i + 1... |
#include <bits/stdc++.h> using namespace std; int n; const long long int MOD = 998244353; class Combination { long long int ppow(long long int i, long long int j) { long long int res = 1LL; while (j) { if ((j & 1LL)) { res *= i; if (res >= MOD) { res %= MO... |
#include<bits/stdc++.h> using namespace std; int t,n; char a[300005],b[300005],c[300005]; void solve(char *x,char *y,int tmp) { // for(int i=1;i<=n*2;i++) cout<<x[i]; // for(int j=1;j<=n*2;j++) cout<<y[j]; // cout<< ! <<endl; // cout<<tmp<<endl; int l1=1,l2=1; for(int i=1;i<=n*3;i++) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, k, x, y; long long b[100005], c[100005]; int a[100005], l[100005], r[100005], d[100005]; int main() { cin >> n >> m >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> l[i] >> r[i] >> d[i]; for (int i = 1; ... |
#include <bits/stdc++.h> using namespace std; inline char gc() { static char now[1 << 16], *S, *T; if (T == S) { T = (S = now) + fread(now, 1, 1 << 16, stdin); if (T == S) return EOF; } return *S++; } inline long long read() { register long long x = 0, f = 1; char ch = gc(); ... |
#include <bits/stdc++.h> using namespace std; int n; int v[100000], c[100000], l[100000], r[100000]; vector<int> g[300001]; int d[200001] = {}; vector<int> p[200001], pp[200001], px[200001]; vector<int> t; int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < (int)(n);... |
#include <bits/stdc++.h> using namespace std; int main() { double n, t, x = 1.000000011; scanf( %lf%lf , &n, &t); double res = n * pow(x, t); printf( %.12lf , res); return 0; } |
#include <bits/stdc++.h> using namespace std; set<long long> mod; int main() { long long n, k; scanf( %I64d%I64d , &n, &k); bool result = true; for (long long i = 1LL; i <= k; i++) { long long x = n % i; if (mod.find(x) != mod.end()) { result = false; break; } ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 100; char ch[maxn]; namespace Suffix_Array { int cntA[maxn], cntB[maxn], tsa[maxn], A[maxn], B[maxn]; int sa[maxn], rkrk[maxn], height[maxn]; void GetSa(char *ch, int n) { for (int i = 0; i < maxn; i++) cntA[i] = 0; for (int i = ... |
#include <bits/stdc++.h> using namespace std; long long lim; long long n, mod; int m; inline long long F(long long a, long long d, long long want, long long n) { if (want == 0 or lim < a) { return 0; } if (n == want) { n = min(n, (lim - a) / d + 1); long long z = 2 * a + (n - 1) ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 300000 + 100; int p[maxn << 2]; void pushdown(int L, int R, int u) { if (L != R) { if (p[u] != -1) { p[u << 1] = p[u]; p[u << 1 | 1] = p[u]; p[u] = -1; } } } void update(int cL, int cR, int val, int L,... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long cases, no_points, xcoord, ycoord; cin >> cases; for (int i = 0; i < cases; i++) { vector <long long> xpoints; vector <long long> ypoints; ... |
#include <bits/stdc++.h> using namespace std; int n; int a[4]; int check(int a, int b, int c, int d) { int avg = a + b + c + d; int med = b + c; if (avg % 4 != 0 || med % 2 != 0) return 0; if (avg / 4 == d - a && med / 2 == d - a) return 1; return 0; } int main() { ios_base::sync_wit... |
#include <bits/stdc++.h> inline long long Input() { long long ret = 0; bool isN = 0; char c = getchar(); while (c < 0 || c > 9 ) { if (c == - ) isN = 1; c = getchar(); } while (c >= 0 && c <= 9 ) { ret = ret * 10 + c - 0 ; c = getchar(); } return isN ? -... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3fffffff; const int maxn = 110; char a[20]; int k; int main() { scanf( %s , a); cin >> k; int len = strlen(a); for (int i = 0; i < len; ++i) { int p = i; for (int j = 1; j <= k && j + i < len; ++j) if (a[i + ... |
#include <bits/stdc++.h> using namespace std; int n, k, tt[40], qq[10]; long long int m[10][41]; vector<int> ss[10]; int check(int c, long long int s) { if (c == k) return (s == 0) || ((s + (s & (-s))) == (1LL << n)); int i, z = ss[c].size() - qq[c] - __builtin_popcountll(s & m[c][0]); s &= ~m[c][... |
#include <bits/stdc++.h> using namespace std; int n, k, num[100001], mxn, contador; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> num[i]; } if (n == 1) { cout << 1; return 0; } for (int i = 2; i < n; i++) { if (num[i] == num[i - 1] + num[i - 2]) ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e2 + 5; string grid[N]; bool found, vis[N][N]; ; int n, m, k, cnt, ans; vector<pair<int, pair<int, int> > > p; int dr[] = {-1, 1, 0, 0}; int dc[] = {0, 0, -1, 1}; bool check(int r, int c) { return r == 0 || r == n - 1 || c == 0 || c ==... |
#include <bits/stdc++.h> using namespace std; string elimina(string s) { for (int i = 0; i < int(s.size()); i++) { if (s[i] == ) or s[i] == ( or s[i] == , or s[i] == . ) s[i] = ; } return s; } int main() { string ss; int n; cin >> n; getline(cin, ss); map<string, ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, t; cin >> t; while (t--) { cin >> a >> b; c = ceil(abs(a - b) / 10.0); cout << c << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; constexpr int64_t P0 = 2000003; constexpr int64_t P1 = 2000017; constexpr int64_t M0 = 3000000000013; constexpr int64_t M1 = 2000000000003; class TaskC { public: struct Class { int id; int cnt; }; struct Hash { int64_t a, b; ... |
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; struct Node { string str; int pos; friend bool operator<(Node const& n1, Node const& n2) { return n2.str < n1.str; } }; priority_queue<Node> que; int main() { int k; string str; cin >> str; cin >>... |
#include <bits/stdc++.h> using namespace std; int main() { char a[1000010], b[1000010]; while (scanf( %s%s , &a, &b) != EOF) { int len1 = strlen(a); int len2 = strlen(b); int ans = 0; if (len1 != len2) { ans = 1; } else { if (len1 == 1) { if (a[0] != b... |
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << << name << : << arg1 << n ; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1,... |
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1e-11; void fastIO() { std::ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } int main() { fastIO(); int n, a; cin >> n; int tot = 0; int mx = 0; for (int i = 0; i < n; i... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); int arr[n]; bool fl = false; for (int i = 0; i < n; i++) { scanf( %d , &arr[i]); if (arr[i] == 1) { fl = true; } } if (fl == false) printf( EASY ); else printf( HA... |
#include <bits/stdc++.h> using namespace std; int arr[105]; int main() { int n; int k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> arr[i]; int count = 105; int ans; for (int i = 0; i < n; i++) { if (k % arr[i] == 0) { ans = k / arr[i]; } count = min(coun... |
#include <bits/stdc++.h> int memo[3][105], n; char map[3][105]; int f(int x, int y) { if (y >= n) return 2; if (memo[x][y] == 0) { if (map[x][y + 1] != . ) return memo[x][y] = 1; int ret = 0; if (map[x][y + 1] == . && map[x][y + 2] == . && map[x][y + 3] == . ) ret |= f(x, y... |
#include <bits/stdc++.h> using namespace std; char tr[100005]; map<char, int> p; char num[12] = { AHIMOTUVWXY }; char num1[27] = { ABCDEFGHIJKLMNOPQRSTUVWXYZ }; void init() { int i; for (i = 0; i < 26; i++) { p[num1[i]] = 0; } for (i = 0; i < 11; i++) { p[num[i]] = 1; } } ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a[100]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int time = 10; int solvedCount = 0; int penalty = 0; for (int i = 0; i < n; i++) { time = time + a[i]; if (time <= 720) { s... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t; cin >> t; while (t--) { long long int n; cin >> n; cout << n << endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; map<int,int> m; for(int i=0,x; i < n; ++i) { cin >> x; m[x]++; } map<int,int> m2; for(auto p : m) { m2[p.second]++; } int cnt,mn=n; for(auto p1 : m2) {... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:167772160 ) using namespace std; const int inf = 1000000000; long long k[1001], p[1001], f[1001], c[1001]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> k[i] >> c[i]; for (int i = 1; i <= n; i++) for (int j = i ... |
#include <bits/stdc++.h> using namespace std; long long b[150005], up[150005], a[150005]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; bool fl = false; cin >> n; for (int i = 1; i <= n; i++) { cin >> b[i]; up[i] = max(1ll, b[i]); if (b[i] != 0) fl = true;... |
#include <bits/stdc++.h> using namespace std; const int N = 1005; template <typename T> inline void read(T &AKNOI) { T x = 0, flag = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == - ) flag = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - 0 ; ... |
#include <bits/stdc++.h> const long long maxn = 1e4 + 10; inline long long Max(long long a, long long b) { return a > b ? a : b; } inline long long Min(long long a, long long b) { return a > b ? b : a; } namespace FastIO { inline long long read() { long long f = 1, r = 0; char c = getchar(); while... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long u, long long v) { while (v != 0) { long long r = u % v; u = v; v = r; } return u; } typedef struct State { char cnt[21]; char top[3]; } State; inline bool operator<(const State &a, const State &b) { ... |
#include <bits/stdc++.h> using namespace std; long long n, m, k; long long gcd(long long x, long long y) { if (!y) return x; return gcd(y, x % y); } int main() { scanf( %I64d%I64d%I64d , &n, &m, &k); if (n * m * 2 % k) { printf( NO ); return 0; } long long x = gcd(n * m * 2... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) #pragma GCC optimization( unroll-loops ) using namespace std; const long long MAX = 1000004; const long long INF = 1e18L + 5; template <class T, class U> void chmin(T &t, const U &u) { if (t > u) t = u; } t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.