func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void add(int &a, int b) { a += b; if (a >= mod) a -= mod; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> dp(20002), pre(20002, 0); int zero = 10000; int ans = 0; for... |
#include <bits/stdc++.h> using namespace std; int n, k; map<int, int> m; string s; long long ans; bool flag; void solve() { cin >> n; cin >> k; vector<int> a(n); int maxi = 0; for (auto i = 0; i < n; i++) cin >> a[i]; ; for (auto i = 0; i < n; i++) { maxi = max(maxi, a[i]... |
#include <bits/stdc++.h> const int S = 400004; int last, tr[S][26], fail[S], len[S], tot = 0, eg = 1, h[S], nx[S << 1], v[S << 1], e[S]; char c[S]; void insert(int &last, char c) { c -= a ; int p = last, now = ++tot; len[now] = len[last] + 1; while (p != ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 + 3; void read(int &x) { char ch; bool flag = 0; for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == - )) || 1); ch = getchar()) ; for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar()) ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 10000000; int main() { int n; string s; scanf( %d , &n); cin >> s; for (int i = 0; i < s.size(); i++) { for (int j = 1; j < 25; j++) { if (i + j * 4 < 100) { if (s[i] == * && s[i + j] == * && s[i + ... |
#include <bits/stdc++.h> using namespace std; template <typename T> void print_array(T* arr, int num) { for (int(i) = (0); (i) < (num); (i)++) cout << arr[i] << ; cout << n ; } template <typename T> void print_vector(vector<T> vec) { for (int(i) = (0); (i) < (vec.size()); (i)++) cout << vec... |
#include <bits/stdc++.h> using namespace std; int main() { int n, k; double L, v1, v2; cin >> n >> L >> v1 >> v2 >> k; double p = 2 * (n / k - (n % k == 0)) + 1; printf( %.10f , double(L * (p * v2 + v1)) / double(v2 * (p * v1 + v2))); } |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt; cin >> tt; while (tt--) { int k; cin >> k; string s, a, b; cin >> s >> a >> b; int n = (int)(s).size(); vector<int> x; vecto... |
#include <bits/stdc++.h> using namespace std; struct Point { long long x, y; int id; }; long long judge(Point p0, Point p1, Point p2) { return (p1.x - p0.x) * (p2.y - p1.y) - (p2.x - p1.x) * (p1.y - p0.y); } long long cmp(Point a, Point b) { if (a.x == b.x) return a.y < b.y; return a.x <... |
#include <bits/stdc++.h> using namespace std; int clique_size(vector<int> *graph, vector<int> &govs, int *visited, int starting) { visited[starting] = 1; int size = 1; for (int i = 0; i < graph[starting].size(); i++) { if (!visited[graph[starting][i]]) { size += clique_si... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long s = 0; bool f = 0; char ch = ; while (!isdigit(ch)) { f |= (ch == - ); ch = getchar(); } while (isdigit(ch)) { s = (s << 3) + (s << 1) + (ch ^ 48); ch = getchar(); } return (... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e9; long long sum(long long l, long long r) { return (l + r) * (r - l + 1) / 2; } int main() { long long n, H; cin >> n >> H; long long l = H, r = 2e9, ans = -1; while (l <= r) { long long mid = (l + r) >> 1; if (n >=... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d n , &n); string str; getline(cin, str); int ans = 0; int subans = 0; for (int i = 0; i < n; i++) { if (str[i] != ) { int ascii = (int)str[i]; if (ascii >= 65 && ascii <= 90) { s... |
#include <bits/stdc++.h> using namespace std; long long s, x; string S, X; long long dp[64][2]; long long d__p(int i, int st) { if (i == S.size() && st) return 0; else if (i == S.size()) return 1; long long &res = dp[i][st]; if (res != -1) return res; res = 0; int x = S[i] ... |
#include <bits/stdc++.h> using namespace std; class DREAD { friend int fread(); static const int buff_max = 20000000 + 10; char buf[buff_max], *pt; public: void clear() { for (; isspace(*pt); ++pt) ; } void Init() { buf[fread(buf, 1, buff_max, stdin)] = EOF; p... |
#include <bits/stdc++.h> #pragma GCC optimize( O3 ) using namespace std; enum { MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009 }; template <typename T> ostream &operator<<(ostream &cout, vector<T> &a) { for (size_t i = 0; i < a.size(); ++i) cout << a[i] << ; return cout; } template <ty... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const double err = 1e-12; const double PI = 3.141592653589793; const int N = 1e5 + 5; int n; vector<int> res; void solve() { cin >> n; if (n & 1) { cout << 1 << ; n--; for (int i = 2; i <= n; i += 2... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 55; long long f[maxn][maxn][maxn][maxn]; long long pw[maxn]; int c[maxn]; void init() { f[0][0][0][0] = 1; pw[0] = 1; for (int i = 1; i < maxn; i++) pw[i] = (pw[i - 1] * 2ll) % mod; } long long cal(int ... |
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 6; vector<int> G[N]; int d[N]; void dfs(int u, int f, int dep) { d[u] = dep; for (int i = 0, iend = G[u].size(); i < iend; ++i) { int v = G[u][i]; if (v != f) dfs(v, u, dep + 1); } } int main() { int T; scanf... |
#include<bits/stdc++.h> #define int long long #define f first #define s second #define N 1010 #define M 1010 #define MOD 998244353 #define oo 1e18 using namespace std; typedef pair<int,int> ii; int v[N][N], estado[N]; set<int>freq[N][N]; int n; void eraseLine(int line, queue<int>&unique) { ... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ii = pair<ll, ll>; using vi = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; constexpr int INF = 2000000000; constexpr ll LLINF = 900000... |
#include <bits/stdc++.h> int main() { int n; std::cin >> n; int a[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) std::cin >> a[i][j]; int sum = 0; int l = (n - 1) / 2, j = n - 1; for (int i = 0; i < n; i++) { sum = sum + a[i][l] + a[l][i] + a[i][i] + a[i][j--]; ... |
#include <bits/stdc++.h> const int mxn = 1 << 19, mod = 998244353; inline int qpow(int x, int n) { int ans = 1; for (; n; n >>= 1, x = 1LL * x * x % mod) if (n & 1) ans = 1LL * ans * x % mod; return ans; } int r[mxn], w[mxn]; void fft_init(int n) { for (int i = 1; i < n - 1; ++i) r[i] = ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 40; long long int dp[maxn][maxn], P[maxn], par[maxn][maxn]; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); P[0] = 1; for (int i = 1; i < maxn; i++) P[i] = P[i - 1] * 10; cin >> s >> s; for (int i = ((i... |
#include <bits/stdc++.h> #pragma GCC optimize( Ofast ) using namespace std; int b[5005], cnt, pr[800], f[800][5001], n, at[5005], sum[800][5001]; long long ans; int ss[5005], tmp[5005], sa, st; int main() { for (int i = 2; i <= 5000; i++) { if (b[i]) continue; for (int j = 2; j * i <= 5000; ... |
#include <bits/stdc++.h> using namespace std; const long long M = 200100; long long b[M]; long long fre[M]; int main() { long long n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; b[a[i]]++; fre[b[a[i]]]++; } long long q; cin >> q; ... |
#include <bits/stdc++.h> #define int long long int const int INF = 1e9 + 7; using namespace std; const int m = 1e9 + 7; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; string a[n], b[n]; for (int i = 0; i < n;... |
#include <bits/stdc++.h> using namespace std; const int maxlen = 81; char s[maxlen]; int base; long long int greedy(int r) { if (!r) return 0; int l = r; long long val = 0, t = 1; for (int i = r; i >= 1 && t < base; --i, t *= 10) if (val + (s[i] - 0 ) * t < base) { val += (s[i] ... |
#include <bits/stdc++.h> using namespace std; const int MX = 100000; long long l[MX], a[MX + 1], mn[MX + 1]; char s[MX + 1]; int main() { int n; ignore = scanf( %d , &n); for (int i = 0; i < n; i++) ignore = scanf( %lld , l + i); ignore = scanf( %s , s); long long e = 0, ans = 0; for (... |
#include <bits/stdc++.h> using namespace std; long long ax, ay, bx, by, tx, ty; int n; long long x[110000]; long long y[110000]; long double solve(int cnt) { long double res = 0; int p = 0; long double v = sqrt((x[0] - ax) * (x[0] - ax) + (y[0] - ay) * (y[0] - ay)) - sqrt((x[... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b; cin >> a >> b; int result = a; int temp = 0; while ((a + temp) >= b) { int t1 = temp; result += (a + temp) / b; temp = (a + temp) % b; a = (a + t1) / b; } cout << result << endl; return 0; ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 100000 + 10; struct node { int x, h; int num; int ans; }; node a[maxn]; int ans[maxn]; stack<int> s; int n; void init() { cin >> n; for (int i = 1; i <= n; i++) { a[i].num = i; cin >> a[i].x >> a[i].h; }... |
#include <bits/stdc++.h> using namespace std; const int N = 100000 + 50; const int X = 1024; int n, k, x; int arr[N]; int freq[X], freq2[X]; inline void brute() { int seen_till = 0; for (int i = 0; i < X; i++) { if (freq[i] != 0) { if (!seen_till) { int dec = (freq[i] + 1) ... |
#include <bits/stdc++.h> using namespace std; int n, m, OO = 1e8; int dp[100001]; int solve(int x) { if (x <= 0 || x > 1e5) return OO; if (x == m) return 0; int &ret = dp[x]; if (ret != -1) return ret; ret = OO; if (x > m) ret = min(ret, 1 + solve(x - 1)); else { ret = mi... |
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; vector<int> *mapo; long long Montgomery(long long a, long long b) { long long ans = 1; a = a % mod; while (b > 0) { if (b & 1) ans = ans * a % mod; b >>= 1; a = a * a % mod; } return ans; } bool in... |
#include <bits/stdc++.h> using namespace std; int main() { int x, y, x1, y1, a, b, c, d, e; cin >> x >> y >> x1 >> y1; a = x1 - x; b = y1 - y; { if (a < 0) { c = (-1) * a; } else c = a; } { if (b < 0) { d = (-1) * b; } else d = b; ... |
#include <bits/stdc++.h> using namespace std; const int infint = 1e9; const long long inf = 1e18; const int MOD = (int)1e9 + 7; const int MAXN = (int)3e5 + 7; const int LOG = 17; int a[MAXN], n, IL[MAXN], IR[MAXN], Lp, Rp, ans, L, R; pair<int, int> G, seg[LOG][2 * MAXN]; pair<int, int> operator*(const... |
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n; double res, t = 1e99; cin >> a >> b >> n; int x, y, v; int i; for (i = 0; i < n; i++) { cin >> x >> y >> v; res = hypot(x - a + 0., y - b + 0.) / v; t = min(t, res); } printf( %.10f n , t); ... |
#include <bits/stdc++.h> using namespace std; /* * * * * * * * * * */ #define mp make_pair typedef long long ll; typedef long double ld; typedef pair<int, int> pii; /* * * * * * * * * * */ /* * * * Too many mind, no mind. * * */ bool can(int med, int k, vector <int> &a) { int ... |
#include <bits/stdc++.h> using namespace std; const int N = 22; int cache[1 << N]; int next_element[1 << N]; int already_done(const vector<int>& adj); int memo(int set, const vector<int>& adj); int main() { int n, m; cin >> n >> m; vector<int> adj(n); for (int i = 0; i < m; i++) { in... |
#include <bits/stdc++.h> const long long MOD = 1e9 + 7; const long long MAXN = 35000 + 1; using namespace std; long long readInt() { bool minus1 = false; long long result = 0; char ch; ch = getchar(); while (true) { if (ch == - ) break; if (ch >= 0 && ch <= 9 ) break; c... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 0; i < n; i++) { cout << 1 ; } cout << endl; } retur... |
#include <bits/stdc++.h> using namespace std; int n; char s[256]; int vis[8]; int main() { while (~scanf( %d , &n)) { scanf( %s , s); int len = strlen(s); if (n % 4) { printf( === n ); continue; } for (int i = 0; i < n; i++) { if (s[i] == A ) ... |
#include <bits/stdc++.h> using namespace std; int main() { double n; cin >> n; while (n--) { double ele; cin >> ele; if (ele < 4 && ele > 0) cout << N n ; else { double a = (ele + sqrt((ele * ele) - (4 * ele))) / 2; double b = (ele - sqrt((ele * ele) - (4... |
/* THINK ALOUD !! */ #include <bits/stdc++.h> using namespace std; using ll=long long int; using lld=long double; #define mp make_pair #define pb push_back #define accu accumulate #define vi vector<int> #define vb vector<bool> #define vc vector<char> #define vd vector<double> #define vl... |
#include <bits/stdc++.h> using namespace std; inline long long read() { long long w = 0, x = 0; char c = getchar(); while (!isdigit(c)) w |= c == - , c = getchar(); while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar(); return w ? -x : x; } namespace star { const long long ... |
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long m = 0, cost = 0; ; int a, b; priority_queue<pair<int, int> > q; for (int i = 0; i < s.size(); i++) { m--; if (s[i] == ( ) m += 2; if (s[i] == ? ) { s[i] = ) ; cin... |
#include <bits/stdc++.h> using namespace std; int32_t main() { vector<int> a; vector<string> size = { S , M , L , XL , XXL }; int i; int n = 5; for (i = 0; i < 5; i++) { int x; cin >> x; a.push_back(x); } int q; cin >> q; while (q--) { int k = 0; ... |
#include <bits/stdc++.h> using namespace std; template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> auto dud(c* x) -> decltype(cerr << *x, 0); template <class c> char dud(...); struct debug { template <class c... |
#include <bits/stdc++.h> using namespace std; int main() { int x, sum1 = 0, Min = 0, sum = 0; cin >> x; int p; vector<int> v; for (int j = 0; j < x; j++) { cin >> p; sum += p; v.push_back(p); } sort(v.begin(), v.end()); int s = v.size(); sum1 = 0; for (int i... |
#include <bits/stdc++.h> using namespace std; char gc() { static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++; } long long read() { char ch = getchar(); long long x = 0; int o... |
#include <bits/stdc++.h> using namespace std; map<int, int> frontc; map<int, int> backc; int main() { int n, ans, a, b, x, i, x1; cin >> n; ans = n; for (i = 0; i < n; i++) { cin >> a >> b; if (a != b) backc[b]++; frontc[a]++; } map<int, int>::iterator it; for (it =... |
#include <bits/stdc++.h> using namespace std; const int N = 100001; void print(vector<int>& vec) { printf( ? ); for (int i : vec) printf( %d , i); printf( n ); fflush(stdout); } int main() { int n, k; scanf( %d%d , &n, &k); vector<int> tmp; for (int i = 1; i <= k + 1; i++) {... |
#include <bits/stdc++.h> using namespace std; vector<string> names; char *cnames[] = { Anka , Chapay , Cleo , Troll , Dracul , Snowy , Hexadecimal }; int n = 7; int id(const string &s) { for (int i = 0; i < (int(names.size())); ++i) if (s == names[i]) return i; }... |
#include <bits/stdc++.h> int main() { int a, b, c, x = 0; scanf( %d%d%d , &a, &b, &c); if ((a + b) <= c) { x = x + (c - (a + b)) + 1; } if ((b + c) <= a) { x = x + (a - (b + c)) + 1; } if ((a + c) <= b) { x = x + (b - (a + c)) + 1; } printf( %d , x); return 0;... |
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (a % b == 0) return b; else return gcd(b, a % b); } long long lcm(long long a, long long b) { double d = (double)(a * b); return (long long)d / gcd(a, b); } int main() { long long i, j,... |
#include <bits/stdc++.h> using namespace std; const int inf = 1 << 30; const int mod = 998244353; const int maxn = 2005; string s; long long ans = 0; int n; vector<pair<int, int> > edges[maxn]; int col[maxn], vis[maxn]; int isbi = 1; void flood(int x, int curcol) { if (vis[x]) { if (col[... |
#include <bits/stdc++.h> using namespace std; int n, m; char mp[510][510]; int minln, maxln, minrw, maxrw, cnt; int main() { scanf( %d%d , &n, &m); for (int i = 1; i <= n; i++) scanf( %s , mp[i] + 1); minln = n + 1; maxln = 0; minrw = m + 1; maxrw = 0; for (int i = 1; i <= n; i++) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf( %d , &n); vector<int> p(n); for (int i = 0; i < n; ++i) cin >> p[i]; double ans = 0; int cnt[102] = {0}; double loser[102] = {0}; for (int i = 0; i < n; ++i) loser[i] = 1.0; for (int i = 1; i < n; ++i) { ... |
#include <bits/stdc++.h> using namespace std; int n, m, k; vector<int> adj[100005]; int col[100005], att[100005], dep[100005]; void dfs(int u, int d = 1, int p = -1) { att[d] = u, dep[u] = d, col[u] = (d & 1) + 1; for (int& v : adj[u]) if (v != p) { if (dep[v] && d - dep[v] + 1 >= k) { ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<vector<int> > a(n, vector<int>(n)); vector<int> b(n * n), q(n * n); for (int i = 0; i < n * n; ++i) { cin >> b[i]; q[i] = i; } do { for (int i = 0; i < n; ++i) for (int j = 0; j <... |
#include <bits/stdc++.h> using namespace std; int n, m, p1[2010][2010], p2[2010][2010], p3[2010][2010], p4[2010][2010]; int sun[2010][2010]; int dir[8][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {-1, 1}, {1, -1}, {1, 1}}; int vis[2010][2010]; int nw, nwr, bel[4000010], cnt[400001... |
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000007 + 1; const int N = 200000; long long a[200006], b[200006]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; long long mx = 0; int cnt2 = 0; for (int i = 0; i < n; i... |
#include <bits/stdc++.h> const int MAXN = 100100; int st[20][MAXN]; char str[MAXN]; int n; void SparseTable() { for (int i = 0; i < n; i++) st[0][i] = i; for (int j = 1; (1 << j) < n; j++) for (int i = 0; i + (1 << (j - 1)) < n; i++) st[j][i] = (str[st[j - 1][i]] >= str[st[j - 1][i + (1 ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m; scanf( %d %d , &n, &m); vector<pair<int, int> > f(n); vector<int> b(m); vector<int> array(1000005, 0); for (int i = 0; i < n; i++) { int temp; scanf( %d , &temp); array[temp]++; f.push_back(make_pair... |
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; int cnt = 0, val; for (int k = 0; k < n; k++) { cin >> val; cnt += val; } if (n == 1 && val == 1) cout << YES ; else if (cnt == n - 1 && n != 1) cout << YES ; else cout <... |
#include <bits/stdc++.h> using namespace std; int INF = 1000000005; long long INFF = 1000000000000000005LL; int main() { long long s, n; cin >> s >> n; long long x, y; vector<pair<long long, long long>> strengths; for (long long i = 0; i < n; i++) { cin >> x >> y; strengths.push_... |
#include <bits/stdc++.h> using namespace std; int main() { int t, s, q; cin >> t >> s >> q; int cnt = 0; while (s < t) { s = s * q; cnt++; } cout << cnt << endl; } |
#include <bits/stdc++.h> using namespace std; const int N = 100100, M = 200200; int i, j, k, n, q, m, nm, ch, ii; int l[N], r[N], fg[N]; struct cc { int x, y; } t, A[M], P[M]; void R(int &x) { x = 0; ch = getchar(); while (ch < 0 || 9 < ch) ch = getchar(); while ( 0 <= ch && ch <=... |
#include <bits/stdc++.h> using namespace std; int main() { int length; bool true_false; char S[100], aux, digits[4] = 123 ; cin >> S; length = strlen(S); for (int i = 0, x = 0, j; i < length; i += 2) { true_false = false; if (S[i] != digits[x]) { for (j = i + 2; j < leng... |
#include <bits/stdc++.h> using namespace std; long long k, n, a, b, val; void solve() { cin >> k >> n >> a >> b; k -= a * n; if (k <= 0) { k *= -1, k++; val = (k + a - b - 1) / (a - b); if (val > n) { cout << -1 << endl; return; } n -= val; } cout ... |
#include <bits/stdc++.h> using namespace std; char arr[108]; int main() { int i, j, k, t, n, m, a, b, c, x, y, z; cin >> n; int flag = 0; for (i = 1; i <= n; i++) { cin >> arr[i]; } int gap, cnt = 0; for (i = 1; i <= n; i++) { if (arr[i] == * ) { for (j = i + 1; j ... |
#include <stdio.h> #include <math.h> #include<bits/stdc++.h> using namespace std; // C = a^2 - b and C^2 = a^2 + b^2 hence (a^2 - b)^2 = a^2 + b^2 , evaluate and subtract then, a^2 = 2*b+1 // Since a^2 - b = C , then 2*b+1 - b = C , then C = b+1 !!!!! , We can observe that the difference between b and c... |
#include <bits/stdc++.h> const int mod = 1000000007; int k, w; int fac[1000010]; int invfac[1000010]; inline int gcd(int a, int b, int &x, int &y) { if (b == 0) { x = 1; y = 0; return a; } int d = gcd(b, a % b, x, y); int t = x; x = y; y = t - a / b * y; return d;... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1 << 18; int n, r; double sum = 0; long long c[MAXN + 10]; int main() { scanf( %d%d , &n, &r); for (int i = 0; i < (1 << n); i++) { scanf( %lld , &c[i]); sum += c[i]; } double dv = 1 << n; printf( %.9lf n , sum / ... |
#include <bits/stdc++.h> using namespace std; bool exceed(long long x, long long y, long long m) { return x >= m / y + 1; } long long n, k; long long a[105]; vector<long long> vec; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; for (long long(i) = (1); (i) <= (k); (i)++... |
#include <bits/stdc++.h> using namespace std; const int M = 1e2 + 10; long long int n, m, x, y, cnt[M][M], ask, mx, mn = 1e18; void go(long long int k, long long int i, long long int j, long long int dir) { if (k == 0) return; cnt[i][j]++; if (j < m) go(k - 1, i, j + 1, dir); else if (dir ... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18 + 239; vector<long long> used; vector<vector<pair<long long, long long> > > gr; long long ans = -inf; vector<long long> dp; long long n; void dfs(long long p1) { used[p1] = 1; if (gr[p1].size() == 1 && p1 != 0) { ans ... |
#include <bits/stdc++.h> using namespace std; int M, R, C, S, T, a[8], b[8], id[8]; vector<vector<vector<int> > > ver; void createVer(int prod, int cur) { if (cur == M) return; for (int i = 1; i <= (int)(a[0]); ++i) for (int j = 1; j <= (int)(prod); ++j) { ver[i][j][cur] = 1; } f... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e9; const int SIZE = 2e5 + 5; const int MOD = 1e9 + 7; void solve(int CASE) { long long x; cin >> x; vector<long long> res; for (long long i = 1; i <= x; i *= 2LL) { res.push_back(i); x -= i; } if (x) res... |
#include <bits/stdc++.h> using namespace std; int main() { long long int x, y; double f, s; cin >> x >> y; f = y * (log10(x)); s = x * (log10(y)); if (abs(f - s) < pow(10, -8)) cout << = ; else if (f < s) cout << < ; else if (f > s) cout << > ; } |
#include <bits/stdc++.h> using namespace std; const int Maxn = 10005; const int Maxb = 31; struct linker { int x, y, id; linker(int x = 0, int y = 0, int id = 0) : x(x), y(y), id(id) {} bool operator<(const linker &b) const { if (y != b.y) return y > b.y; if (x != b.x) return x > b.x; ... |
#include <bits/stdc++.h> #pragma GCC target( avx2 ) #pragma GCC optimization( O3 ) #pragma GCC optimization( unroll-loops ) #pragma GCC optimize( Ofast ) #pragma GCC target( avx,avx2,fma ) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int TC; cin >> TC; while (TC--) { int N; cin >> N; string s; cin >> s; int ans = 0; int cnt = 0; for (int i = N - 1; i >= 0; i--) { if (s[i] == P ) ... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n % 2 == 0) { cout << -1; } else { for (int i = 0; i < n; i++) { cout << (2 * i) % n << ; } cout << endl; cout << 0 << ; for (int i = n - 1; i > 0; i--) { cout <<... |
#include <bits/stdc++.h> using namespace std; int main() { int n, m, a; cin >> n >> m; a = n % m; for (int i = 1; i <= m; i++) { if (a > 0) { cout << n / m + 1 << ; a--; } else { cout << n / m << ; } } } |
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; using ii = pair<int, int>; using vii = vector<ii>; using l = long long; using vl = vector<l>; using vvl = vector<vl>; using ll = pair<l, l>; using vll = vector<ll>; using vvll = vector<vll>; using lu = ... |
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int nax = 1e5 + 10; vector<int> tree(4 * nax); long long i, j, x, y, k; bool sortbysec(const pair<long long, long long> &a, const pair<long long, long long> &b) { return (a.second < b.second); } int main() ... |
#include <bits/stdc++.h> using namespace std; double max(double a, double b) { return a > b ? a : b; } double min(double a, double b) { return a > b ? b : a; } double x[10101], y[10101], z[10101], A, B; int n, m, k; void slv() { double minx = -1; sort(x + 1, x + n + 1); sort(y + 1, y + m + 1); ... |
#include <bits/stdc++.h> using namespace std; const int maxn = 200000 + 10; int n; long long area, cnt; double fac[200], ans, calc; struct Point { long long x, y; Point() {} Point(long long x, long long y) : x(x), y(y) {} Point operator-(const Point& tmp) const { return Point(x - tmp.x... |
#include <bits/stdc++.h> using namespace std; int main() { string x, y; cin >> x >> y; int length = x.length(); for (int i = 0; i < length; i++) { int c = x[i]; if (islower(c)) x[i] = toupper(c); } int length1 = y.length(); for (int i = 0; i < length1; i++) { int c = y[... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; int dp[N], x[N]; int main() { int k, n, b, t; scanf( %d%d%d%d , &k, &n, &b, &t); int lim = min(t, min(n, b)) * n; while (k--) { for (int i = 0; i < n; i++) scanf( %d , &x[i]); memset(dp, 0, sizeof dp); for (... |
#include <bits/stdc++.h> using namespace std; vector<long long> v; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long a = 0, b = 0, c, d, e, f = 0, l, g, m, n, k, i, j, t, p, q; cin >> t; while (t--) { cin >> n; f = 0; v.clear(); ... |
#include <bits/stdc++.h> using namespace std; const long long N = 105; const long long MOD = 1e9 + 7; long long n, m, k; long long cache[N][N * N], cache2[N][N]; long long fact[N], invfact[N]; long long pow(long long a, long long b, long long m) { long long ans = 1; while (b) { if (b & 1) an... |
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 7; const long long INF = (long long)1e9 + 7; char st[N]; map<long long, long long> s[200]; long long c[N]; int main() { int n; long long t, ans = 0, x = 0; for (char i = a ; i <= z ; i++) cin >> c[i]; gets(st); ge... |
#include <bits/stdc++.h> using namespace std; char a[1000011]; int main() { while (~scanf( %s , a)) { int t = strlen(a); if (t % 2 != 0) printf( Impossible n ); else { stack<char> sta; int ans = 0, p = 0; for (int i = 0; i < t; i++) { if (a[i] == { ... |
#include <bits/stdc++.h> using namespace std; typedef long long lli; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pb push_back #define int long long int dp[201][20001]; int numSubseq(int n , vector<int>& a, int s , int pos1 = -2 , int pos2 = -2 ) { if( n == pos1 || n... |
#include <bits/stdc++.h> using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; } int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, m, ta, tb, k; cin >> n >> m >> ta >> tb >> k; long long int a[n], b[m]; fo... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; if (n == 12) { string hour = ; hour += s[0]; hour += s[1]; string min = ; min += s[3]; min += s[4]; if (hour == 00 ) s[0] = 1 ; if (stoi(hour) > 1... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << n * 2 - n / 2; return 0; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.