func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int N =9999999; const double pi=acos(-1); int n,t,ans,a[N],k,s1,s2; int main(){ cin>>t; while(t--){ cin>>n>>k; if(n%2==1)cout<<((k-1)+((k-1))/(n/2))%n+1<<endl; else cout<<(k-1)%n+1<<endl; } return 0; } |
#include <bits/stdc++.h> using namespace std; inline long long int StrToInt(string& s) { long long int ans = 0; for (int i = 0; i < s.size(); i++) ans = ans * 10 + s[i] - 0 ; return ans; } vector<long long int> v, t, pref; long long int bp(long long int mo) { long long int l = 0, r = v.size()... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e6 + 10; string rs; int pre[maxn]; void matchprefix() { int n = rs.length(); pre[0] = 0; int k = 0; for (int i = 1; i < n; i++) { while (k > 0 && rs[k] != rs[i]) k = pre[k - 1]; if (rs[k] == rs[i]) k++; pre[i] = ... |
#include <bits/stdc++.h> using namespace std; int main() { string s1; int count = 0; cin >> s1; char c = s1[0]; for (int i = 0; i < s1.length(); i++) { if (s1[i] == c) count++; else if (s1[i] > c) { count = 1; c = s1[i]; } } cout << string(count,... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast,no-stack-protector ) #pragma GCC optimize( unroll-loops ) #pragma GCC optimize( fast-math ) #pragma GCC optimize( move-loop-invariants ) std::mt19937 rnd(237); using namespace std; using ll = long long; using ld = long double; const int inf = 1e9 + ... |
#include <bits/stdc++.h> using namespace std; int f[3][4] = {{0, 3, 1, 2}, {}, {0, 2, 3, 1}}; void solve(long long x, int y) { if (y == 1) { printf( %lld n , x); return; } long long ans = 0, p = 1; while (x) { ans += f[y][x % 4] * p; x >>= 2, p <<= 2; } printf( %lld... |
#include <bits/stdc++.h> using namespace std; string s[1000 + 5]; int nsc[1000 + 5], nsl[1000 + 5]; int main() { int n, m; cin >> n >> m; int i, j, z; for (i = 0; i < n; i++) cin >> s[i]; for (i = 0; i < n; i++) for (j = 0; j < m; j++) if (s[i][j] == * ) nsl[i]++, nsc[j]++; ... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> inline void chmin(A& a, B b) { if (a > b) a = b; } template <typename A, typename B> inline void chmax(A& a, B b) { if (a < b) a = b; } template <class A, class B> ostream& operator<<(ostream& ost, const pair<A, B>... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long ans = 0; for (int i = (0); i < (n); ++i) { long long t, T, x, cost; cin >> t >> T >> x >> cost; if (t >= T) { ans += cost + m * x; continue; } long long aux1 = ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; int cnt[2], v[2]; bool f(ll val) { ll f[] = {val / v[0], val / v[1]}; ll b = v[0] * 1ll * v[1]; ll both = val / b; ll other = val - f[0] - f[1] + both; f[0] -= both; f[1] -= both; ll tcnt[] = {cnt[0] - f[1], cnt[1] -... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL ... |
#include <bits/stdc++.h> const int N = 5050; int n, t, v = -1, w, p[N], c[N], d[N], l[N]; void U(int x, int* y) { for (int u = x + 1; u <= n; u += u & -u) ++y[u]; } int Q(int x, int* y) { int s = 0; while (x > 0) s += y[x], x -= x & -x; return s; } int main() { scanf( %d , &n); for... |
#include <bits/stdc++.h> using namespace std; vector<long long> ve[100005]; long long vis[100005] = {0}, z = 0, i; void solve() { vector<long long> v; vector<pair<long long, long long> > vp; map<long long, long long> mp, mpp; map<long long, long long>::iterator itr; long long n = 0, m = 0, i... |
#include <bits/stdc++.h> using namespace std; bitset<300000001> b; int main() { int l, r, c = 0, i, j; cin >> l >> r; for (i = 3; i * i <= r; i += 2) for (j = i * i; b[i] == 0 and j <= r; j += i) b[j] = 1; if (l <= 2 and r >= 2) c = 1; for (i = 5; i <= r; i += 4) c += !b[i] and i >= l; ... |
#include <bits/stdc++.h> using namespace std; int b[4], c, n, l = 0, a, i; int main() { scanf( %d , &n); for (i = 0; i < n; i++) { scanf( %d , &a); b[a]++; } cout << n - max(b[1], max(b[2], b[3])) << endl; return 0; } |
#include <bits/stdc++.h> using namespace std; const int INF = 1000 * 1000 * 1000 + 7; const double EPS = 1e-9; int bit_count(int first) { return first == 0 ? 0 : 1 + bit_count(first & (first - 1)); } inline int low_bit(int first) { return first & -first; } inline int sign(double first) { return fi... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; bool count[26] = {0}; char c; for (int i = 0; i < n; i++) { cin >> c; count[c - a ] = true; } int e = -4; int res = 0; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; int n; cin >> n; int k; cin >> k; string s; cin >> s; int ig = -1, it = -1; for (int i = 0; i < n; i++) { if (s[i] == G ) { ig = i; } if (s[i]... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1005; const long long mod = 1000000007; int grid[maxn][maxn]; inline void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); } int main() { fast(); int h, w; cin >> h >> w; for (int i = 0; i < h;... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6; string b[maxn]; int p[maxn], n[maxn]; void get_id(string); bool is_legal(string); int main() { int N; scanf( %d , &N); memset(p, 0, sizeof(p)); memset(n, 0, sizeof(n)); for (int i = 0; i < N; i++) { cin >> b[i]; ... |
#include <bits/stdc++.h> int n, K; int ch[60000][26]; int val[60000]; char st[1000]; int f[60000][1000]; int knum; void add(char *st) { int m = strlen(st + 1); int u = 0; for (int i = 1; i <= m; i++) { if (!ch[u][st[i] - a ]) { knum++; ch[u][st[i] - a ] = knum; } ... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:100000000 ) using namespace std; int n; string s; string A[] = { 123456 , 154236 , 145326 , 516324 , 261453 , 132546 }; string B[] = { 123456 , 523164 , 623541 , 423615 }; vector<string> P; vector<string> T; vector<string> H; bool BB[1... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { long long a, b, c, d; cin >> a >> b >> c >> d; if (a > b * c) cout << -1 << n ; else { long long k = (a / (b * d)); ... |
#include <bits/stdc++.h> using namespace std; long long m, l, r, k, ans; map<long long, long long> F; long long f(long long n) { if (F.count(n)) return F[n]; long long k = n / 2; if (n % 2 == 0) return F[n] = (f(k) * f(k) + f(k - 1) * f(k - 1)) % m; return F[n] = (f(k) * f(k + 1) + f(k - 1) * f(... |
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 3; long long n, x, a, cnt, ans, sum; string g; deque<long long> v; void DNM() { cin >> n; for (long long i = 0; i < n; i++) { cin >> a; v.push_back(a); if (a > 0) cnt = i; } for (long long i = 0; i <= c... |
#include <bits/stdc++.h> using namespace std; int main() { int n, l, r, p, q, w[100000 + 2], ans = 2100000000, sum = 0, sub = 0; scanf( %d%d%d%d%d , &n, &l, &r, &p, &q); for (int i = 0; i < n; i++) { scanf( %d , &w[i]); sum += w[i]; } for (int i = 0; i <= n; i++) { int ret = su... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; cin >> t; while (t--) { long long n, i, g = 0, s = 0, b = 0, j; cin >> n; long long a[n]; vector<long long> v(n, 1); for (i = 0; i < n; i++) { ... |
#include <bits/stdc++.h> using namespace std; signed main() { long long int n, k; cin >> n >> k; long long int arr1[n], arr2[n]; for (long long int i = 0; i < n; i++) cin >> arr1[i]; for (long long int i = 0; i < n; i++) cin >> arr2[i]; multiset<pair<long long int, pair<long long int, long l... |
#include <bits/stdc++.h> using namespace std; int n, a[100010], w[100010], h[100010]; int main() { cin >> n; for (int i = 1; i <= n; i++) scanf( %d%d , &w[i], &h[i]); ; a[n] = min(w[n], h[n]); for (int i = n - 1; i >= 1; i--) { if (min(w[i], h[i]) >= a[i + 1]) a[i] = min(w[i], h[... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000000 + 10; const int inf = (-1u) >> 1; bool v[maxn]; int n, m, k, num; vector<int> g[maxn]; void dfs(int x) { v[x] = true; ++num; for (vector<int>::iterator it = g[x].begin(); it != g[x].end(); ++it) { if (!v[*it]) { ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 66; long long n, k, a[maxn], d[maxn][maxn]; int main(void) { cin >> n >> k; for (int i = 1; i <= n; ++i) { cin >> a[i]; a[i] += a[i - 1]; } long long rt = 0; for (int i = 55; i >= 0; --i) { rt += ((1LL * 1) << i... |
#include <bits/stdc++.h> using namespace std; char xB[1 << 15], *xS = xB, *xTT = xB; template <typename T> inline void rd(T& xaa) { char xchh; T f = 1; xaa = 0; while (xchh = (xS == xTT && (xTT = (xS = xB) + fread(xB, 1, 1 << 15, stdin), xS == xTT) ... |
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; long long mod2 = 998244353; long long mod3 = 1000003; long long mod4 = 998244853; long long inf = 1LL << 60; long double pi = 3.14159265358979323846L; double eps = 1e-12; int dh[4] = {1, -1, 0, 0}; int dw[4] = {0, 0, 1, -1}; ... |
#include<bits/stdc++.h> #include<math.h> using namespace std; #define ll long long #define endl n #define pb push_back #define eraseO(s, x) if(s.find(x) != s.end()) { s.erase(s.lower_bound(x)); } #define vi vector<int> #define vc vector<char> #define vl vector<ll> #defi... |
#include <bits/stdc++.h> using namespace std; int a[100] = {0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4}; int n; int main() { scanf( %d , &n); if (n <= 10) puts( 0 ); else printf( %d n , a[n - 10]); } |
#include <bits/stdc++.h> using namespace std; const int INF = (int)2e9; const long long INFL = (long long)9e18; const int MAXINT = ((~0) ^ (1 << 31)); const long long MAXLL = ((~0) ^ ((long long)1 << 63)); template <class T> inline T pow2(T a) { return a * a; } template <class T> inline bool min... |
#include <bits/stdc++.h> const int N = 5e4 + 5; struct Point { int x, y, z, id; void input() { scanf( %d%d%d , &x, &y, &z); } } a[N]; int main() { std::map<std::pair<int, int>, std::vector<Point> > f; std::map<int, std::vector<Point> > g; std::vector<Point> h; int n; scanf( %d , &n);... |
#include <bits/stdc++.h> using namespace std; void DEBUG(vector<long long> a) { printf( { ); for (long long x : a) printf( %lld , x); printf( } n ); } int mod; void DEBUG(long long mask) { printf( mask: ); for (int i = 0; i < mod; ++i) printf( %d , (mask >> i) & 1); printf( n ); }... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, q = 1, i, res = 1; cin >> n >> m; for (i = 0; i < m; i++) { q = (q << 1); q %= 1000000009; } q--; for (i = 0; i < n; i++) { res *= (q - i); if (res <= 0) { cout << 0 ; return 0... |
#include <bits/stdc++.h> const int maxn = 3005, maxm = maxn << 1; int n, e, ans, minn; int start[maxn], to[maxm], then[maxm], worth[maxm], f[maxn], tot[maxn], xx[maxm], yy[maxm]; inline int min(int a, int b) { return a < b ? a : b; } inline int max(int a, int b) { return a > b ? a : b; } inline void a... |
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 4; int n, A, B, a[N], par[N]; map<int, int> Map; int root(int u) { return (par[u] < 0) ? u : (par[u] = root(par[u])); } void Merge(int u, int v) { u = root(u); v = root(v); if (u != v) { if (par[u] > par[v]) swap(u, v); ... |
#include <bits/stdc++.h> using namespace std; void print(vector<int> v) { for (int i = 0; i < v.size(); i++) { cout << v[i] << ; } cout << n ; return; } bool isSubsetSum(vector<int> set, int n, int sum) { bool subset[n + 1][sum + 1]; for (int i = 0; i <= n; i++) subset[i][0] =... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, m, k, A, B; cin >> n; int r1 = -1, p2 = 100000, p1 = -1; for (int(i) = 0; (i) < (n); (i)++) { int x; cin >> x; r1 = max(x, r1); } cin >> m; for (int(i) = 0; (i) < (m); (i)++) { int x; cin >>... |
#include <bits/stdc++.h> bool isFile; using namespace std; const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1}; const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; void _(); void faster() { _(); if (isFile) { freopen( taskA ... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> v(n); vector<int> cnt(n + 1, 0); for (int i = 0; i < n; i++) { cin >> ... |
#include<bits/stdc++.h> #define maxn 200005 #define endl n using namespace std; int n,m,a[maxn],dis[maxn]; vector<int> e[maxn]; queue<int> q; void bfs() { while(!q.empty()) { int u=q.front(); q.pop(); for(int i=0;i<e[u].size();i++) { int v=e[u][i]; if(dis[v... |
#include <bits/stdc++.h> int main() { int h, l; float a; scanf( %d %d , &h, &l); a = l * tan(atan(1.0 * h / l) - atan(1.0 * l / h)); if (a < 0) a = -a; printf( %.10f , a); return 0; } |
#include <bits/stdc++.h> using namespace std; struct node { double a; int b; friend const bool operator<(const node& x, const node& y) { if (fabs(x.a - y.a) < 1e-10) return x.b < y.b; else return x.a < y.a; } }; int n, t, q, p[200007], l[200007], cnt[200007]; double... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int y, long long int p) { long long int res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } bool sortbysec(const pair<lo... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b; int cnt = 0; cin >> a >> b; long long d = abs(a - b); if (d % 10 == 0) { cout << d / 10 << endl; } else { cout << d / 10 + 1 << endl; } ... |
#include <bits/stdc++.h> using namespace std; vector<int> alph(26, 0); vector<int> comp(26, 0); int main() { int n, t, even = 0, l1, l2; cin >> n; for (int i = 0; i < n; i++) { cin >> t; if (t % 2 == 0) { even++; l1 = i; } else { even--; l2 = i; ... |
#include <bits/stdc++.h> using namespace std; int z = 1000000007; map<int, int> parent; map<int, int> XOR; pair<long long int, long long int> finding(int n, int xo) { if (parent.find(n) == parent.end()) return pair<long long int, long long int>(n, 0); pair<long long int, long long int> temp = fi... |
#include <bits/stdc++.h> using namespace std; int n, m, i, j, k, l, art[505][505], low[505][505], used[505][505], ans, cn, t, x, y, z, mx, mn, s, timer, vis[505][505]; char c[505][505], d[1000009], ch; void dfs(int row, int col) { timer++; used[row][col] = 1; if ((row - 1 >= 0) && (used[row - ... |
#include <bits/stdc++.h> using namespace std; template <class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template <class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } int N; bitset<200013> bs; int nxt[200013]; long long ans; long long c(int r, int m, int mod) { ret... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) #pragma GCC optimize( O1 ) #pragma GCC optimize( O2 ) #pragma GCC optimize( Os ) #pragma GCC optimize( Ofast ) #pragma GCC target( avx2 ) #pragma GCC optimization( unroll-loops ) long long int gcd(long long int a, long long int b) { return (b ? gcd... |
#include <bits/stdc++.h> using namespace std; #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) void solve() { long long n, m, k; cin >> n >> m >> k; long long lb = n / m; long long ub = (n + m - 1) / m; vector<long long> seat; for (long... |
#include <bits/stdc++.h> using namespace std; string a, b, p1 = Widget , p2 = VBox , p3 = HBox , ans[105]; map<string, int> q; vector<int> d[105]; int id[105]; long long l[105], r[105], h1[105], h2[105]; void dfs(int x) { if (l[x] != -1) return; l[x] = 0; for (int i = 0; i < (int)d[x].size(... |
#include <bits/stdc++.h> using namespace std; const int IINF = 0x3f3f3f3f; const long long LINF = 0x3f3f3f3f3f3f3f3fll; const double DINF = numeric_limits<double>::infinity(); const long long MOD = 1000000007; const double EPS = 1e-9; const int DX[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int DY[] = {0, 1,... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, a[maxn], ans; int gcd(int x, int y) { if (y == 0) return x; return gcd(y, x % y); } int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int x = gcd(a[1], a[2]); for (int i = 3; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int n = 0, T = 0; long long D[1003], g[1003]; long long x1[1003], xn[1003], Y1[1003], Yn[1003]; void getDisPre(long long x, int N, long long (&t1)[1003], long long (&tn)[1003]) { if (N == 0) { t1[0] = tn[0] = 0; return; } i... |
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = RDLU ; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? YES : NO ); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { assert(y >=... |
#include <bits/stdc++.h> template <class T> inline bool rd(T &ret) { char c; int sgn; if (c = getchar(), c == EOF) return 0; while (c != - && (c < 0 || c > 9 )) c = getchar(); sgn = (c == - ) ? -1 : 1; ret = (c == - ) ? 0 : (c - 0 ); while (c = getchar(), c >= 0 && c <= 9 ) re... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int hr = s[0] - 0 ; hr = hr * 10 + s[1] - 0 ; if (hr >= 12) hr -= 12; int min = s[3] - 0 ; min = min * 10 + s[4] - 0 ; double b = min * 6; double a = ((double)hr + (double)min / 60) * 30; print... |
#include <bits/stdc++.h> using namespace std; int main() { int t = 0, counterarr[3] = {5, 7, 5}, c = 0; string x; bool arr[3] = {}; while (t < 3) { getline(cin, x); for (int i = 0; i < x.length(); i++) { if (x[i] == a || x[i] == e || x[i] == u || x[i] == i || ... |
#include <bits/stdc++.h> using namespace std; int main() { int sum1 = 0, sum2 = 0, sum3 = 0; int n; cin >> n; int a, b, c; for (int i = 0; i < n; i++) { cin >> a >> b >> c; sum1 += a; sum2 += b; sum3 += c; } if (sum1 == 0 && sum2 == 0 && sum3 == 0) cout << ... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; n *= 2; int arr[n]; vector<int> ans; unordered_set<int> s; for (int i = 0; i < n; i++) { cin >> arr[i]; if (s.find(arr[i]) == s.end()) { ... |
#include <bits/stdc++.h> using namespace std; const int64_t INF = 1e18, MOD = 1e9 + 7; const int64_t MAXN = 1e3; pair<int64_t, int64_t> last = {0, 0}; pair<int64_t, int64_t> ask(int64_t i) { if (i != -1) cout << + << (i + 1) << endl; int64_t a, b; cin >> a >> b; a -= last.first, b -= last.s... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; const int Maxn = 1005; const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, 1, 0, -1}; struct pos { int first, second, third; }; string s; int n, k; pair<int, int> d[11111]; int main() { scanf( %d%d , &n, &k); cin >> s;... |
#include <bits/stdc++.h> using namespace std; int L[100000 + 10], dp1[100000 + 10], dp2[100000 + 10]; int lis(int *seq, int *ls, int N) { int len = 0; for (int i = 1; i <= N; ++i) { int lo = 1, hi = len; while (lo <= hi) { int m = (lo + hi) / 2; if (L[m] <= seq[i]) lo... |
#include <bits/stdc++.h> using namespace std; int n, c0, c1, t0, t1, w0, w1, tot, q[2][1000010]; char s[1000010]; vector<int> v[1000010]; int main() { scanf( %s , s + 1); n = strlen(s + 1); for (int i = (1); i <= (n); i++) if (s[i] == 0 ) c0++; else c1++; if (c0 < ... |
#include <bits/stdc++.h> using namespace std; long long left(long long i, long long n) { if (i == 0) return n - 1; return i - 1; } long long solve(string a, long long n) { long long cw = 0; long long ccw = 0; for (long long i = 0; i < n; i++) { if (a[i] == - ) continue; if (a[i]... |
#include <bits/stdc++.h> int read() { int ans = 0, c, f = 1; while (!isdigit(c = getchar())) if (c == - ) f *= -1; do ans = ans * 10 + c - 0 ; while (isdigit(c = getchar())); return ans * f; } const int N = 10050; int n, A[N], B[N]; int m, a[N], b[N], c[N], d[N]; void por(int x1,... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a, b; cin >> n >> m >> a >> b; int x = m - n, r = 0, t = 14; if (b >= a && a * 8 < x) { cout << -1; return 0; } while (x > 0) { if (10 <= t && t < 22) x -= a; else x += b; t++; ... |
#include <bits/stdc++.h> using namespace std; int main() { string s, str[10]; cin >> s; for (int i = 0; i < 10; i++) cin >> str[i]; for (int i = 0; i < s.length(); i += 10) { string w; for (int j = i; j < i + 10; j++) w = w + s[j]; for (int i = 0; i < 10; i++) { if (w.compa... |
#include <bits/stdc++.h> using namespace std; bool check(string &w, string &s, map<char, int> &cnt) { int used[ z - a + 1] = {}; int arr[ z - a + 1] = {}; for (int i = 0; i < w.size(); ++i) { if (w[i] != * ) { used[w[i] - a ] = 1; } } for (int i = 0; i < w.size(); ++i... |
#include <bits/stdc++.h> using namespace std; void solve() { int n, h; cin >> n >> h; for (int i = 1; i < n; i++) printf( %.10f , h * sqrt(1. * i / n)); puts( ); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; t = 1; while (t--) { solv... |
#include <bits/stdc++.h> using namespace std; const int INF = 1e9; vector<int> primes(int n) { vector<int> p(n + 1, 1); for (int i = 2; i * i <= n; ++i) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = 0; vector<int> res; for (int i = 2; i <= n; ++i) if (p[i]) res.push_back... |
#include <bits/stdc++.h> using namespace std; const int N = 10005; int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } int T, n, A, B, C, cnt, p[N], mu[N], du[N], fe[N], tot; long long a[N], b[N], c[N]; bool np[N]; void init() { mu[1] = 1; for (int i = 2; i <= n; i++) { if (!np[i]) p[++... |
#include <bits/stdc++.h> using namespace std; int main() { int t, m, n, a, ans; cin >> t; while (t--) { ans = 0; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a; ans += a; } if (n > m || n == 2) cout << -1 << endl; else { cout <... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; set<long long> myset; for (int i = 0; i < n; i++) { int c; cin >> c; myset.insert(c); } auto it = myset.begin(); int ans = 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n, k; int a[maxn]; long long pre[maxn]; void read_input() { cin >> n >> k; for (int i = 1; i <= n; ++i) cin >> a[i]; } void init() { for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + a[i]; } vector<int> get_divs... |
#include <bits/stdc++.h> using namespace std; long long s, x; int main() { cin >> s >> x; s -= x; if (s < 0 || s % 2 != 0) { cout << 0 << endl; return 0; } s /= 2; if (s & x) { cout << 0 << endl; return 0; } long long bit = 0, result = 0; if (!s) result ... |
#include <bits/stdc++.h> using namespace std; int main() { long long a, n, trans = 0, cnt = 0, b, c, m, s, d; vector<int> v, vd; cin >> n; for (long long x = 0; x < n; x++) { cin >> m; v.clear(); for (long long j = 0; j < m; j++) { cin >> d; v.push_back(d); } ... |
#include <bits/stdc++.h> using namespace std; int a[303][303], dp[602][301][301], n; bool valid(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < n); } int update(int d, int x1, int x2) { if (x2 < x1) swap(x1, x2); int y1 = d - x1, y2 = d - x2; if (!valid(x1, y1) || !valid(x2, y2)) return INT... |
#include <bits/stdc++.h> using namespace std; vector<pair<long int, long int>> adj[100001]; bool visit[100001] = {}; long int val[100001]; long int ans = 0; void dfs(long int node, long int w) { if (w > val[node]) { return; } ans++; for (long int i = 0; i < (int)adj[node].size(); i++) ... |
#include <bits/stdc++.h> using namespace std; using namespace rel_ops; struct Fraction { long long p, q; static inline __attribute__((always_inline)) long long gcd(long long a, long long b) { while (b ^= a ^= b ^= a = a % b) ; ... |
#include <bits/stdc++.h> using namespace std; void imGonnaDoIt() { long long r, x, y, xx, yy; cin >> r >> x >> y >> xx >> yy; cout << ceil(hypot((x - xx), (y - yy)) / (r * 2)); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); imGonnaDoIt(); return 0; } |
#include <bits/stdc++.h> using namespace std; int main() { map<string, int> puncte, cnt, goluri, rateu; int x, y; char c1[25], c2[25]; for (int i = 0; i < 5; i++) { scanf( %s%s%d:%d , c1, c2, &x, &y); cnt[c1]++; cnt[c2]++; if (x > y) { puncte[c1] += 3; } i... |
#include <bits/stdc++.h> using namespace std; int main() { int i, n; cin >> n; int cnt = 0; int jump = 1; int arr[n]; for (int k = 1; k <= n; k++) { arr[k] = k; } for (i = 1; i <= n * n; i++) { jump += i; if (jump <= n) { cout << arr[jump] << ; } el... |
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; long long sum[55][100005], f[55][100005], t[100005]; int l[55], r[55]; int add(int p, int x, int y) { if (x < 0) return 0; if (y < 0) return sum[p][x]; return sum[p][x] - sum[p][y]; } long long solve1(int n, int m) ... |
#include <bits/stdc++.h> void solve() { int n, z; std::cin >> n >> z; std::vector<int> xs(n); for (auto& x : xs) std::cin >> x; std::sort(xs.begin(), xs.end()); int ok = 0, ng = n / 2 + 1; while (ng - ok > 1) { int k = (ok + ng) / 2; bool judge = true; for (int i = 0; i <... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; bool flag = 0; int by1, by2; int x, y; for (int i = 0; i <= a; i++) { x = a - i; y = i; by1 = b - x; by2 = c - y; if (by1 == by2 and by1 >= 0) { flag = 1; ... |
#include <bits/stdc++.h> using namespace std; long long n, m; string s; long long q; char ch; long long k = 0; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> s; for (long long i = 0; i < n - 1; i++) if (s[i] == . && s[i + 1] == . ) k++; ... |
#include <bits/stdc++.h> using namespace std; int arr[100100]; vector<int> adj[100100]; int cnt[100100]; queue<int> q[2]; int main() { int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) scanf( %d , &arr[i]); for (int i = 0; i < m; ++i) { int u, v; scanf( %d%d , &u, &v); a... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, k; cin >> n >> m >> k; int total = 0; for (int i = 1; i <= n; ++i) { int temp; cin >> temp; if (n - i < m) { total += min(k, temp); } else { total += temp; } } cout << total << ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n; long long int k; cin >> n; cin >> k; long long int arr[k]; for (long long int i = 0; i < k; i++) cin >> arr[i]; long long minrem = n % arr[0]; long long number = 0; long long pos = 0; for (long long i... |
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 10; const int M = 128; const int inf = 0x7fffffff; const long long INF = 9E18; const int mod = 1e9 + 7; int tree[maxn << 2][2], a[maxn]; int in[maxn], out[maxn], dis[maxn]; int dfs_clock = 0; vector<int> g[maxn]; void dfs(int u, ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; int n, q, ans; int mat[maxn][maxn]; int main() { cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { int k; scanf( %d , &k); if (i == j) { ans += k; } } } ... |
#include <bits/stdc++.h> using namespace std; const int N = 81; const int inf = 1e9; int n, c, a[N]; int dp[N][N][N * N]; vector<int> vc; int main() { scanf( %d , &n); c = 0; for (int i = 1; i <= n; i++) { scanf( %d , &a[i]); c += a[i]; if (a[i]) vc.push_back(i); } in... |
#include <bits/stdc++.h> using namespace std; void cass() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const int N = 10; int n, a[N], res = 1e9, x[N]; string s; void read() { cin >> s; n = 6; for (int i = 0; i < s.length(); ++i) a[i + 1] = s[i] - 0 ; } void cmp() { ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.