func_code_string stringlengths 59 71.4k |
|---|
#include <bits/stdc++.h> using namespace std; int n; double p[110], S = 0, P = 1, ans; int main() { scanf( %d , &n); for (int i = 1; i <= n; i++) scanf( %lf , &p[i]); sort(p + 1, p + n + 1); for (int i = n; i >= 1; i--) if (1.0 - S >= 1e-12) { ans += P * p[i] * (1 - S); S +... |
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int x[N], p[N], n, d, ind[N]; long long ans = 0; vector<pair<int, int> > tank; int head, cur; bool cmp(int a, int b) { return x[a] < x[b]; } bool use(int dis) { while (dis) { if (head == (int)tank.size()) return 1; int ... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 1, INF = 1e17, MOD = 1e9 + 7; long long n; string s, t = UDRL ; map<char, long long> m; int32_t main() { ios_base::sync_with_stdio(0); cin >> n >> s; for (long long i = 0; i < n; ++i) { m[s[i]]++; } cout <<... |
#include <bits/stdc++.h> using namespace std; char buffer[100000], *p1, *p2; template <class T> void read(T& x) { char ch = ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, 100000, stdin), p1 == p2)) ? EOF : *p1++); x = 0; bool f = 1; whi... |
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const int N = 1000000 + 10; const int M = 1000; const string st2 = ABCDEFGHIJKLMNOPQRSTUVWXYZ ; const string s1 = abcdefghijklmnopqrstuvwxyz ; pair<int, int> a[N]; int b[N]; string ans[N], da[N]; int main() { cin >... |
#include<bits/stdc++.h> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef long double ld; #define fr(i,a,b) for(ll i=a; i<b; i++) #define rf(i,a,b) for(ll i=a; i>=b; i--) #define pb push_back #define mp make_pair #define show(a) for(auto el:a)cout<<el<< #d... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 300000 + 10; int n, a[MAXN], p[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> a[i], p[a[i]] = i; for (int i = 0; i < n; i++) { for (int j = min(i ... |
#include <bits/stdc++.h> using namespace std; template <class T> ostream& operator<<(ostream& os, vector<T> V) { os << [ ; for (auto v : V) os << v << ; return os << ] ; } template <class T> ostream& operator<<(ostream& os, set<T> S) { os << { ; for (auto s : S) os << s << ; ... |
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define int long long #define pb push_back #define endl n #define ff first #define ss second #define FIO ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); #defin... |
#include <bits/stdc++.h> using namespace std; const long long MAXN = 2e5 + 7; long long parent[MAXN], rank1[MAXN]; vector<pair<long long, pair<long long, long long>>> edges; void makest(long long v) { parent[v] = v; rank1[v] = 0; } long long find(long long v) { if (v == parent[v]) return v; ... |
#include <bits/stdc++.h> using namespace std; long long a, b, n, k, h; int main() { int arr[3]; cin >> arr[0] >> arr[1] >> arr[2]; int y = 1, b = 2, r = 3; while (y < arr[0] && b < arr[1] && r < arr[2]) { y++; r++; b++; } cout << y + b + r; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, SQ = 780; const long long inf = 1e18; long long dp[2][SQ]; vector<int> v[maxn]; int n, m; long long ans; int main() { scanf( %d%d , &n, &m); for (int i = 0; i < m; i++) { int a, b; scanf( %d%d , &a, &b); i... |
#include <bits/stdc++.h> using namespace std; long long modex(long long a, long long b) { long long ans = 1LL; while (b) { if (b % 2) { ans *= a; ans %= 1000000009; } a *= a; a %= 1000000009; b /= 2LL; } return ans; } int main() { ios::sync_with_... |
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b; cin >> a >> b; if ((abs(a - b)) % 2) { cout << -1 << endl; continue; } if (a == b && b == 0) { cout << 0 << endl; continue; } if (... |
#include <bits/stdc++.h> using namespace std; inline int ckmax(int &a, int b) { return a < b ? a = b, 1 : 0; } inline int ckmin(int &a, int b) { return a > b ? a = b, 1 : 0; } int n, r, x[1010]; double y[1010]; int main() { scanf( %d%d , &n, &r); for (int i = 1; i <= n; ++i) { scanf( %d , x + ... |
#include <bits/stdc++.h> using namespace std; template <typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> a) { return o << a.first << << a.second; } template <typename A, typename B> istream& operator>>(istream& o, pair<A, B>& a) { return o >> a.first >> a.second; } const in... |
#include <bits/stdc++.h> using namespace std; int n, a[1005]; long long dp[1005]; long long dpsum[1005]; bool b[1005]; long long ch[1005][1005]; long long gc(int c, int x) { if (x == 0 || c == x) return 1; if (!ch[c][x]) { ch[c][x] = (gc(c - 1, x - 1) + gc(c - 1, x)) % 998244353; } r... |
#include <bits/stdc++.h> using namespace std; int main() { short n, pos, l, r; cin >> n >> pos >> l >> r; if (1 == l && n == r) { cout << 0 ; return 0; } if (1 == l) { cout << abs(r - pos) + 1; return 0; } if (n == r) { cout << abs(pos - l) + 1; retur... |
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t,n; cin>>t; while(t--) { cin>>n; string str; cin>>str; int cnt_t=0,cnt_m=0; for(int ... |
#include <bits/stdc++.h> using namespace std; char getc() { char c = getchar(); while ((c < A || c > Z ) && (c < a || c > z ) && (c < 0 || c > 9 )) c = getchar(); return c; } int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); } int read() { int x = 0, f = 1; char c =... |
#include <bits/stdc++.h> using namespace std; bool pal(string s) { long long n = s.size(); for (long long i = 0; i < n / 2; i++) if (s[i] != s[n - i - 1]) return false; return true; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long te... |
#include <bits/stdc++.h> using namespace std; const int maxn = 550; char grid[maxn][maxn]; int rdp[maxn][maxn], cdp[maxn][maxn], dp[maxn][maxn]; int val[maxn][maxn]; int main() { int n, m, q, c1, c2, r1, r2; scanf( %d%d , &n, &m); for (int i = 0; i < n; i++) scanf( %s , grid[i]); for (int i ... |
#include <bits/stdc++.h> using namespace std; int main() { float H, L; cin >> H >> L; float x; x = ((L * L) - (H * H)) / (2 * H); printf( %0.6f , x); return 0; } |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 100, maxp = 20; int n, a[maxp][maxp], ma[(1 << maxp)], cur[1 << maxp], dp[1 << maxp], cnt[maxn], f[maxp][maxn]; int ans, mp, p; char s[maxn]; vector<int> pos[20]; void solve() { dp[mp] = 1; for (int i = mp; i >= 0; i--) { ... |
#include <bits/stdc++.h> using namespace std; long long n, l, r, ans = 0; bool kk(long long x, long long i) { if (x == 1) { if (i == 1) return 1; else return 0; } else { long long t = 1, g; while (t <= x) t *= 2; t--; g = t / 2; if (g + 1 == i) { ... |
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const int INF = 1061109567; const long long LINF = 4557430888798830399ll; void TestCase() { long long d; scanf( %lld , &d); d %= 360; if (d < 0) d += 360; int ans = INF, cnt = 0; for (int i = 0; i < 4; ++i) { ... |
#include <bits/stdc++.h> using namespace std; long long lpow(long long a, long long n) { long long c = 1ll; while (n) { if (n % 2) c = (c * a) % 1000000007ll; a = (a * a) % 1000000007ll; n /= 2; } return c; } long long c[104][105], C[105][105], a[10005]; int main() { long... |
#include <bits/stdc++.h> using namespace std; char s[3010][3010], t[3010][3010], S[3010], T[3010]; int nxt[3010], len, pos, tl, tr, p[3010], pre[3010][3010], n, len_s[3010]; void change(int id) { int n = strlen(s[id] + 1), j = 0; for (int i = 1; i <= n; i++) { while (j && S[j + 1] != s[id][i]) j =... |
#include<bits/stdc++.h> #define int long long #define reg register using namespace std; const int maxn=5e5+5; const int mod=1e9+7; const int INF=2e9; inline int read() { int x=0,f=1; char ch=getchar(); while(ch< 0 || ch> 9 ) { if(ch== - ) f=-1; ch=g... |
#include <bits/stdc++.h> using namespace std; long long ans1, ans2; int n; char s[111111]; long long a[111111], pa[111111], b[111111], pb[111111]; inline long long get(long long x, int first) { long long t = first, ans = 0; while (t <= x) { ans += (x + 1 - t); t += 2; } return an... |
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int idx[2 * n + 1], chk = 2 * n; vector<long long int> coin; coin.push_back(0LL); for (long long int i = 1; i <= 2 * n; i++) { ... |
#include <bits/stdc++.h> using namespace std; long long n, p[10]; map<long long, string> m; set<long long> s[10]; template <class T> string toString(T x) { ostringstream os; os << x; return os.str(); } int getlen(long long x) { int ans = 0; while (x) { ans++; x /= 10; ... |
#include <bits/stdc++.h> using namespace std; int main() { long long n, v; cin >> n >> v; map<int, int> s; for (int i = 1; i <= n; i++) { long long a; cin >> a; for (int j = 0; j < a; j++) { long long b; cin >> b; if (v > b) { s[i] = 1; } ... |
#include <bits/stdc++.h> using namespace std; enum { AABB, ABAB, ABBA, AAAA }; int n, k; string s1, s2, s3, s4; bool isvow(char c) { return (c == a || c == e || c == i || c == o || c == u ); } string suf(string s) { static int sp = 0; auto i = s.end(), beg = s.begin(); int tk = 0;... |
#include <bits/stdc++.h> using namespace std; template <typename T> struct outputer; struct outputable {}; template <typename T> inline auto sqr(T x) -> decltype(x * x) { return x * x; } template <typename T1, typename T2> inline bool umx(T1& a, T2 b) { if (a < b) { a = b; return 1... |
#include <bits/stdc++.h> using namespace std; const int N = 400010; vector<pair<int, long long> > forc[N]; vector<pair<int, pair<int, long long> > > other[N]; vector<pair<int, pair<int, long long> > > centroid[N]; long long dist[N]; int sub[N]; bool alive[N]; int belongs[N]; vector<pair<int, int> > ... |
#include <bits/stdc++.h> using namespace std; int n, m, A, B, inf = 1e9, f[110][110], x, y, K, g[110][110], Cnt[110], d[110][110]; bool vis[110][110], V[110][110], Must[110][110]; vector<int> E1[110], E2[110], E[110][110]; queue<pair<int, int> > h; void read(int &x) { char ch = getchar... |
#include <bits/stdc++.h> using namespace std; string S; signed long long mo = 1000000007; int N; string qs[100005]; signed long long memo[20][100005]; signed long long dig[20][100005]; void solve() { int i, j, k, l, r, x, y; string s; cin >> qs[0]; cin >> N; N++; qs[0] = 0-> + ... |
#include <bits/stdc++.h> using namespace std; const double eps = 1e-8; const double pi = acos(-1); const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3f; const int N = 2e5 + 5; int n, m, idx; char s[N], ans[N]; bool st[10]; set<int> all; bool check(int x) { if (x == 2) return 0;... |
#include <bits/stdc++.h> int main() { int n, m, sum = 0, i, j; int a[500][3], b[500][3]; scanf( %d , &n); for (i = 0; i < n; i++) scanf( %d %d %d , &a[i][0], &a[i][1], &a[i][2]); scanf( %d , &m); for (i = 0; i < m; i++) scanf( %d %d %d , &b[i][0], &b[i][1], &b[i][2]); for (i = 0; i < n; i+... |
#include <bits/stdc++.h> using namespace std; pair<long long, long long> a[100001]; long long start = 0; long long h; long long res; long long c[100001]; long long n; int main() { ios_base::sync_with_stdio(false); cin >> n >> h; for (int i = 1; i <= n; ++i) { cin >> a[i].first; a... |
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; clock_t timeStart, timeFinish; void timeBegin() { timeStart = clock(); } void timeEnd() { timeFinish = clock(); } void timeDuration() { double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC); cout << Time take... |
#include <bits/stdc++.h> using namespace std; struct Dinic { static const int MXN = (int)2e6; struct Edge { int v, f, re; }; int n, s, t, level[MXN]; vector<Edge> E[MXN]; void init(int _n, int _s, int _t) { n = _n; s = _s; t = _t; } void add_edge(int u, int v,... |
#include <bits/stdc++.h> using namespace std; long long int power(long long int x, long long int n) { if (x == 0) return 0; if (n == 0) return 1; if (n == 1) return x; if (n % 2 == 0) { long long int temp = power(x, n / 2); return (temp % 1000000007 * temp % 1000000007) % 1000000007; ... |
#include <bits/stdc++.h> using namespace std; long long int ara[1000005], n, m, dp[1005][1005]; long long int func(long long int i, long long int j) { if ((j + ara[i]) % m == 0) { return 1; } if (i >= n - 1) { if ((j + ara[i]) % m == 0) { return 1; } else return 0; ... |
#include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); std::cout.tie(0); } long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } void solve() { lo... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1100; int a[MAXN]; int main() { int n, k; while (scanf( %d%d , &n, &k) != EOF) { for (int i = 0; i < n; i++) scanf( %d , &a[i]); int res = 0; int sum = (1 << 29); for (int i = 0; i < n; i++) { int tmp = 0, fla... |
#include <bits/stdc++.h> using namespace std; const long long M = 1000000000000000003LL; int n, m; long long pow2[262144]; char S[262144]; char T[262144]; long long hS[262144][26]; long long hT[262144][26]; long long curh[26]; vector<int> ans; bool v[26]; inline long long mulmod(long long x, lon... |
#include <bits/stdc++.h> using namespace std; const long long inf = 1e15; const long double pi = 3.141592; const long long mod1 = 1e9 + 7; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int n; cin >> n; vector<int> d(n + 1); set<int> set; int x = 1, y = 1; int m... |
#include <bits/stdc++.h> using namespace std; const int INF = ~(1 << 31); int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); } int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; int m = 0, l = 0; for (int i = 1; i < n; i++) { if (v[i]... |
#include <bits/stdc++.h> using namespace std; const int mod = 1000000000 + 7; const int MAX = 100000; map<pair<string, int>, int> F; vector<pair<string, int>> v, ans; pair<string, int> q; set<string> s; int n; vector<int> g[300000]; vector<int> S[300000]; bool used[300000]; bool cmp(int i1, int ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, x, y, m{99999}; cin >> n; int* A = new int[n]; for (int i{0}; i < n; i++) cin >> A[i]; for (int i{0}; i < n; i++) { int s{0}; for (int j{0}; j < A[i]; j++) { cin >> x; s += x; } y = (15 * A[... |
#include <bits/stdc++.h> using namespace std; const int N = 1003, mod = 998244353; template <typename T> void read(T &x) { int ch = getchar(); x = 0; bool f = false; for (; ch < 0 || ch > 9 ; ch = getchar()) f |= ch == - ; for (; ch >= 0 && ch <= 9 ; ch = getchar()) x = x * 10 + ch - ... |
#include <bits/stdc++.h> using namespace std; namespace fastIO { bool IOerror = 0; inline bool blank(char ch) { return ch == || ch == n || ch == r || ch == t ; } inline long long read() { bool sign = 0; char ch = getchar(); long long x = 0; for (; blank(ch); ch = getchar()) ... |
#include <bits/stdc++.h> using namespace std; namespace mincostflow { struct edge { int to, cap, cost, rev; edge(int to = 0, int cap = 0, int cost = 0, int rev = 0) : to(to), cap(cap), cost(cost), rev(rev) {} }; vector<edge> g[7000]; int dist[7000], q[7000 * 2]; int frome[7000], fromv[7000... |
#include <bits/stdc++.h> using namespace std; map<int, int> lc, rc, pr; set<int> nodes; set<int>::iterator it; vector<int> v; int main() { int n; cin >> n; int root; cin >> root; nodes.insert(root); for (int i = 1; i < n; ++i) { int x; cin >> x; v.push_back(x); ... |
#include <bits/stdc++.h> using namespace std; int R[300010 * 2], L[300010 * 2], n, m, sum[300010], sz; struct Fun { int k, b; } f[300010], id[300010 * 20], s[300010]; inline int Read() { char c = getchar(); int num = 0, f = 1; while ( 0 > c || c > 9 ) { if (c == - ) f = -1; c = ... |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; queue<int> r, d; char c; for (int i = 0; i < n; i++) { cin >> c; if (c == D ) d.push(i); else r.push(i); } while (r.size() != 0 && d.size() != 0... |
#include <bits/stdc++.h> using namespace std; template <class T> bool checkmax(T &a, T b) { return a < b ? a = b, true : false; } template <class T> bool checkmin(T &a, T b) { return a > b ? a = b, true : false; } template <class T> void string_reader(string s, vector<T> &vec) { istringstr... |
#include <bits/stdc++.h> using namespace std; inline int Get() { int x = 0, f = 1; char ch = getchar(); while (ch < 0 || ch > 9 ) { if (ch == - ) f = -1; ch = getchar(); } while ( 0 <= ch && ch <= 9 ) { x = (x << 1) + (x << 3) + ch - 0 ; ch = getchar(); } r... |
#include <bits/stdc++.h> using namespace std; const int maxn = 310; int l[maxn], c[maxn]; int n; int f[1 << 9]; int g[maxn][10], cnt[maxn]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> l[i]; for (int i = 1; i <= n; i++) cin >> c[i]; for (int i = 1; i <= n; i++) { int x ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 * 3 + 10; int n, k, m; vector<int> graph[2][MAXN]; int p[2][MAXN]; int sum; void read_input() { scanf( %d , &n); scanf( %d , &k); int v; for (int i = 0; i < k - 1; i++) { sum++; scanf( %d , &v); graph[0][n... |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; if (n > 1) sort(a, a + n); int cont = 0; if (k == n) { cout << a[k - 1] << n ; } els... |
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 5; long long v[N]; signed main() { long long n; cin >> n; long long p = 2 * n; long long x = p * (p + 1); if (x % 4 == 0) cout << NO n ; else { cout << YES n ; for (long long i = 1; i <= 2 * n; i+... |
#include <bits/stdc++.h> #pragma comment(linker, /STACK:16000000 ) using namespace std; const int Maxn = 505; const int Maxk = 11; const int Maxd = 10; const int Inf = 1000000000; int n, k; string s; int w; struct trie { trie *ch[Maxd]; int cnt; trie() { for (int i = 0; i < Maxd; ... |
#include <bits/stdc++.h> using namespace std; long long n, m, w, r, k, i, j, s, q, x, y, l, a[22000]; int main() { ios_base::sync_with_stdio(0); cin >> n; for (i = 1; i <= n; i++) { cin >> a[i], s += a[i]; if (a[i] < 0) k = 1; } if (k == 0) { cout << s; return 0; } ... |
#include<bits/stdc++.h> using namespace std; int main() { long long t,n,x; cin>>t; while(t--) { cin>>n>>x; long long a[n+1],m=30,j,s=0,k,c; for (long long i = 0; i < n; ++i) { cin>>a[i]; k=a[i]; c=0; while(k%x==0) { k/=x; c++; } if (m>c) ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2005; int n, m, k, l[MAXN][MAXN], r[MAXN][MAXN]; char S[MAXN]; int a[MAXN][MAXN], dp[MAXN][MAXN], x[MAXN], y[MAXN], ans[MAXN]; void clr(int i) { for (int j = 1; j <= m; ++j) l[i][j] = a[i][j] ? 0 : l[i][j - 1] + 1; for (int j = m; j >= 1... |
#include <bits/stdc++.h> using namespace std; void setIO(string name = ) { ios_base::sync_with_stdio(0); cin.tie(0); if (!name.empty()) { freopen((name + .in ).c_str(), r , stdin); freopen((name + .out ).c_str(), w , stdout); } } long long calc(long long a, long long b) { retur... |
#include <bits/stdc++.h> using namespace std; const int N = 4e5 + 2; signed main() { ios::sync_with_stdio(false); cin.tie(0); srand(time(NULL)); int N; long long sa = 0, sb = 0; cin >> N; vector<int> A(N), B(N), ind(N); iota(ind.begin(), ind.end(), 0); for (int i = 0; i < N; ++... |
#include <bits/stdc++.h> using namespace std; bool lucky(int n) { n = abs(n); if (n == 8) return true; while (n) { int x = n % 10; if (x == 8) return true; n /= 10; } return false; } int main() { int n; scanf( %d , &n); for (int i = 1; i <= 100; i++) { int... |
#include <bits/stdc++.h> using namespace std; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x, T y) { x = min(x, y); } template <typename T> void read(T &x) { x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = ge... |
#include <bits/stdc++.h> using namespace std; int p[2005], c[2005]; int n, root = -1; vector<int> v[2005]; int d[2005], vis[2005]; int ans[2005]; struct cmp { bool operator()(int x, int y) { return d[x] > d[y]; } }; priority_queue<int, vector<int>, cmp> q; void dfs(int x) { if (c[x] == 0) q.... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; vector<pair<int, int> > g; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b; g.push_back(make_pair(a, b)); } sort(g.begin(), g.end()); int mx = 0, ans = 0; for (int i = 0; i < n; i++) { if ... |
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } int spf[15000005], ans[15000002]; void sieve() { spf[1] = 1; for (int i = 2; i < 15000002; i++) spf[i] = i; for (int i = 4; i < 15000002; i += 2) spf[i] = 2; for (int i =... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string name; ostringstream convert; for (int i = 1; i <= n; i++) { convert << i; name = convert.str(); } cout << name[n - 1]; return 0; } |
#include <bits/stdc++.h> using namespace std; int fx[] = {1, 0, 0, -1}; int fy[] = {0, -1, 1, 0}; int n, m; int data[1002][1002], dist[1002][1002]; void bfs(int sx, int sy) { for (int i = 0; i < 1002; i++) { for (int j = 0; j < 1002; j++) dist[i][j] = INT_MAX; } queue<int> q; q.push(sx... |
#include <bits/stdc++.h> using namespace std; const int mxN = 210; int n, a[mxN], pos[mxN][3]; int next(int i) { if (pos[a[i]][0] == i) return pos[a[i]][1]; return pos[a[i]][0]; } void upd(int u, int v) { if (pos[a[u]][0] == u) pos[a[u]][0] = v; else pos[a[u]][1] = v; } bool ... |
#include <bits/stdc++.h> using namespace std; const int N = 100010; int f[256], b[8]; vector<pair<int, int>> a; int main() { int n, m, k; scanf( %d%d%d , &n, &m, &k); for (int i = 1; i <= n; i++) { int l, r; scanf( %d%d , &l, &r); a.push_back({l, i}); a.push_back({r + 1, -i... |
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int N = 3e5 + 100; int a[N], n; long long ans; void update(int i, int c) { if (i <= 0 || i > n) return; if (a[i] > a[i - 1] && a[i] > a[i + 1]) ans += a[i] * c; if (a[i] < a[i - 1] && a[i] < a[i + 1]) ans -= a[i] * c... |
#include <bits/stdc++.h> int main() { int n, i, sum = 0; char str[51]; scanf( %s , &str); n = strlen(str); for (i = 0; i < n; i = i + 1) { if (str[i] == a ) { sum++; } } if (sum > n / 2) { printf( %d n , n); } else { printf( %d n , 2 * sum - 1); } ... |
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; vector<long long int> v; cin >> n >> k; long long int r; for (long long int i = 0; i < n; i++) { long long int a; cin >> a; v.push_back(a); } r = v[0] % k; long long int mn = 100000000000... |
#include <bits/stdc++.h> using namespace std; template <typename T> string NumberToString(T Number) { std::ostringstream second; second << Number; return second.str(); } long long qpow(long long p, long long q) { long long f = 1; while (q) { if (q & 1) f = f * p % 1000000007LL; ... |
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } template <typename T> string to_str(T str) { stringstream stream; stream << str; return stream.str(... |
#include <bits/stdc++.h> using namespace std; long double esp = 1e-11; const long double PI = acos(-1.0); const long long int INF = 0x3f3f3f3f; const long long int MOD = 1000000007; const int maxn = 10010; const int NUM = 25; long long int wn[NUM]; long long int mu(long long int a, long long int b, lo... |
#include <bits/stdc++.h> int res[1000008]; using namespace std; int main() { bool pr[1000008 + 1]; memset(pr, true, sizeof(pr)); int cnt = 0; for (int p = 2; p * p <= 1000008; p++) { if (pr[p] == true) { for (int j = p * p; j <= 1000008; j += p) pr[j] = false; } } for (... |
#include <bits/stdc++.h> using namespace std; long long ans[1000005]; long long n; struct cht { vector<pair<long long, long long> > v; long long pt = 0; long long val(long long pos, long long x) { return v[pos].first * x + v[pos].second; } bool lmao(pair<long long, long long> p0, pair<... |
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using uint = unsigned int; using ull = unsigned long long; using ii = pair<int, int>; using pli = pair<ll, int>; using vi = vector<int>; using vll = vector<ll>; using pll = pair<ll, ll>; using pil = pair<in... |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 1e6 + 5; int a[N], m[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, b; cin >> n >> b; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = n; i >= 0; --i... |
#include <bits/stdc++.h> using namespace std; int a[1005]; int main() { int n, maxp, mx2p; scanf( %d , &n); for (register int i = 1; i <= n; ++i) { scanf( %d , a + i); } if (a[1] > a[2]) { maxp = 1; mx2p = 2; } else { maxp = 2; mx2p = 1; } for (registe... |
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 2) { cout << white n1 2 n ; } else if (n % 2 == 0) { cout << white n1 2 n ; } else { cout << black n ; } } |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int l, r; cin >> l >> r; cout << l << << l * 2 << n ; } return 0; } |
#include <bits/stdc++.h> using namespace std; inline long long add(long long x, long long y) { x += y; if (x >= 1000000007) x -= 1000000007; return x; } inline long long sub(long long x, long long y) { x -= y; if (x < 0) x += 1000000007; return x; } inline long long mul(long long x, ... |
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5; set<int> v[MAXN]; int last = -1, lastx = -1; vector<int> f; int ans = 0; int t[MAXN], x_[MAXN]; bool find(vector<int> &d, int k) { if (d.empty()) return false; int l = 0, r = int(d.size()); while (r - l > 1) { int m = ... |
#include <bits/stdc++.h> using namespace std; int n, t1, t2, t3, t4, t5, dif, yes, rep, cnt[1005], last[1005], ans[1005][1005], ma[1005][1005]; vector<int> nod, re, v[1005]; vector<pair<int, int> > path, more; vector<pair<pair<int, int>, int> > sol; bool vis[1005]; pair<int, int> pl, pr; bool ok; ... |
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int r = 0; for (int i = 1; i < 300; i++) { int x1 = a / i; int x2 = b / i; if (x1 + x2 >= n && x1 != 0 && x2 != 0) r = i; } cout << r; return 0; } |
#include <bits/stdc++.h> using namespace std; const int N = 1e5; long long dmod(long long x, long long MOD) { return x % MOD; } long long m; long long fe(long long x, long long p) { if (p == 0) return 1; long long ret = fe(x, p / 2); ret = dmod(ret * ret, m); if (p & 1) ret = dmod(ret * x, m);... |
#include <bits/stdc++.h> using namespace std; long long dp[300300]; int a[300300], h[300300], d[300300]; vector<int> ans; inline void calc(int i) { int mn = min(a[i], a[i + 1]); if (!mn) return; ans.push_back(i); a[i] -= mn, a[i + 1] -= mn; } int main() { int n; scanf( %d , &n); ... |
#include <bits/stdc++.h> using namespace std; vector<string> a; long long i, j, k, sumA = 0, sumB = 0, min_sumA = 8, min_sumB = 8; string t; int main() { for (i = 0; i < 8; i++) { cin >> t; a.push_back(t); } for (i = 0; i < 8; i++) for (j = 0; j < 8; j++) { sumA = sumB = ... |
#include <bits/stdc++.h> using namespace std; bool good(int x, int y, int n) { return x >= 0 && y >= 0 && x < n && y < n; } int main() { cin.tie(0); cin.sync_with_stdio(0); int x; cin >> x; for (int i = 1; i <= 200; i += 2) { int n = i; int o = 1; int t = (n / 2) * 2; i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.