diff --git a/Codeforces/1227C b/Codeforces/1227C new file mode 100755 index 0000000..b32ef6d Binary files /dev/null and b/Codeforces/1227C differ diff --git a/Codeforces/1227C.cpp b/Codeforces/1227C.cpp new file mode 100644 index 0000000..a17d1fe --- /dev/null +++ b/Codeforces/1227C.cpp @@ -0,0 +1,93 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +const int N = 2050; +char s[N], t[N]; +vector> v; +int main() +{ + int T, n, k; + read(T); + while (T--) + { + v.clear(); + read(n, k); + scanf("%s", s); + int sp = 0; + for (int i = 0; i < k - 1; i++) t[sp++] = '(', t[sp++] = ')'; + for (int i = 0; i < (n >> 1) - k + 1; i++) t[sp++] = '('; + for (int i = 0; i < (n >> 1) - k + 1; i++) t[sp++] = ')'; + for (int i = 0; i < n; i++) + if (s[i] != t[i]) + { + auto po = strchr(s + i, t[i]); + reverse(s + i, po + 1); + v.push_back({i + 1, po - s + 1}); + } + printf("%d\n", (int)v.size()); + for (const auto &p : v) printf("%d %d\n", p.first, p.second); + } + return 0; +} \ No newline at end of file diff --git a/Codeforces/1227D1 b/Codeforces/1227D1 new file mode 100755 index 0000000..dd20c00 Binary files /dev/null and b/Codeforces/1227D1 differ diff --git a/Codeforces/1227D1.cpp b/Codeforces/1227D1.cpp new file mode 100644 index 0000000..69efd31 --- /dev/null +++ b/Codeforces/1227D1.cpp @@ -0,0 +1,92 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int a[105], b[105]; +int main() +{ + int n, m, k, p; + read(n); + for (int i = 0; i < n; i++) read(a[i]); + memcpy(b, a, sizeof(int) * n); + sort(b, b + n, greater()); + read(m); + while (m--) + { + read(k, p); + int x = b[k - 1]; + int gx = lower_bound(b, b + n, x, greater()) - b; + for (int i = 0, j = 0, l = 0; i < n; i++) + { + if (a[i] > x) j++; + if (a[i] == x && l < k - gx) j++, l++; + if (j == p) + { + printf("%d\n", a[i]); + break; + } + } + } + return 0; +} \ No newline at end of file diff --git a/Codeforces/1260C b/Codeforces/1260C new file mode 100755 index 0000000..610ed8e Binary files /dev/null and b/Codeforces/1260C differ diff --git a/Codeforces/1260C.cpp b/Codeforces/1260C.cpp new file mode 100644 index 0000000..eacb9fe --- /dev/null +++ b/Codeforces/1260C.cpp @@ -0,0 +1,79 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPX(op, t, x) operator op(CRP(t, x)) +#define OPL(t, x) bool OPX(<, t, x) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef int64_t ll, i64; +typedef uint64_t ull, u64; +template +using comtype = typename common_type::type; +template +using enable_if_arithmetic = typename enable_if::value>::type; +template +using enable_if_integral = typename enable_if::value>::type; +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf; + return S == T ? EOF : *S++; +} +template > +inline bool read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == EOF) + return false; + else if (ch == '-') + f = 0; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + return x = f ? x : -x, true; +} +template > +inline bool read(T &x, Args &... args) { return read(x) && read(args...); } +template > +inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min(v1, v2); } +template > +inline TResult mmin(CRP(T, v), const Args &... args) { return min(v, mmin(args...)); } +template > +inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max(v1, v2); } +template > +inline TResult mmax(CRP(T, v), const Args &... args) { return max(v, mmax(args...)); } +inline ll gcd(ll a, ll b) +{ + for (; b; swap(a, b)) a %= b; + return a; +} +inline ll fpow(ll a, ll b, ll m) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) r = r * a % m; + return r; +} +constexpr double eps = 1e-8; +inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; } +int main() +{ + ll T, r, b, k; + read(T); + while (T--) + { + read(r, b, k); + ll g = gcd(r, b); + r /= g, b /= g; + if (r > b) swap(r, b); + puts((k - 1) * r + 1 < b ? "REBEL" : "OBEY"); + } + return 0; +} \ No newline at end of file diff --git a/hdu872/6734.cpp b/hdu872/6734.cpp new file mode 100644 index 0000000..2e22379 --- /dev/null +++ b/hdu872/6734.cpp @@ -0,0 +1,28 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(t, x)) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef long long ll, i64; +int main() +{ + int T, n; + scanf("%d", &T); + while (T--) + { + scanf("%d", &n); + while (n % 2 == 0) n /= 2; + while (n % 5 == 0) n /= 5; + puts(n > 1 ? "Yes" : "No"); + } + return 0; +} \ No newline at end of file diff --git a/hdu872/6736.cpp b/hdu872/6736.cpp new file mode 100644 index 0000000..a091465 --- /dev/null +++ b/hdu872/6736.cpp @@ -0,0 +1,63 @@ +#define _CRT_SECURE_NO_WARNINGS +#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +#include +using namespace std; +#define CRP(t, x) const t &x +#define OPL(t, x) bool operator<(CRP(t, x)) const +#define FIL(x, v) memset(x, v, sizeof(x)) +#define CLR(x) FIL(x, 0) +#define NE1(x) FIL(x, -1) +#define INF(x) FIL(x, 0x3f) +#ifndef _DEBUG +#define _DEBUG 0 +#endif // !_DEBUG +#define IFD if (_DEBUG) +typedef long long ll, i64; +ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } +constexpr ll mod = 998244353; +ll fpow(ll a, ll b) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % mod) + if (b & 1) + r = r * a % mod; + return r; +} +ll fpow(ll a, ll b, ll m = mod) +{ + ll r = 1; + for (; b; b >>= 1, a = a * a % m) + if (b & 1) + r = r * a % m; + return r; +} +inline char getchar(int) +{ + static char buf[64 << 20], *S = buf, *T = buf; + if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + S; + return S == T ? EOF : *S++; +} +template +using isInt = typename enable_if::value>::type; +template > +inline void read(T &x) +{ + int ch = x = 0, f = 1; + while (!isdigit(ch = getchar())) + if (ch == '-') f = -1; + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; + x *= f; +} +template > +inline void read(T &x, Args &... args) { read(x), read(args...); } +int main() +{ + int a, b, c, d; + double e; + read(a, b, c, d); + cout << a << endl; + cout << b << endl; + cout << c << endl; + cout << d << endl; + return 0; +} \ No newline at end of file