diff --git a/hdu853/01.cpp b/hdu853/01.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/01.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/02.cpp b/hdu853/02.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/02.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/03.cpp b/hdu853/03.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/03.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/04.cpp b/hdu853/04.cpp new file mode 100644 index 0000000..3973d0d --- /dev/null +++ b/hdu853/04.cpp @@ -0,0 +1,50 @@ +#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) +typedef long long ll, i64; +ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } +struct prob +{ + int a, b; + OPL(prob, rhs) { return a < rhs.a || (a == rhs.a && b > rhs.b); } +}; +int main() +{ + int T, n; + scanf("%d", &T); + while (T--) + { + priority_queue H; + ll hi = 0, lo = 1, g, asum = 0; + scanf("%d", &n); + for (int i = 0; i < n; i++) + { + prob p; + scanf("%d%d", &p.a, &p.b); + if (p.a > p.b) swap(p.a, p.b); + H.push(p); + asum += p.a; + if (i & 1 ^ 1) + { + p = H.top(); + hi = (asum - p.a) * (p.a + p.b) + p.a * p.b; + lo = p.a + p.b; + } + else + { + hi = asum, lo = 1; + } + g = gcd(hi, lo); + hi /= g, lo /= g; + printf("%lld/%lld\n", hi, lo); + } + } + return 0; +} \ No newline at end of file diff --git a/hdu853/05.cpp b/hdu853/05.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/05.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/06.cpp b/hdu853/06.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/06.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/07.cpp b/hdu853/07.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/07.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/08.cpp b/hdu853/08.cpp new file mode 100644 index 0000000..77802af --- /dev/null +++ b/hdu853/08.cpp @@ -0,0 +1,39 @@ +#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) +typedef long long ll, i64; +ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } +ll f(ll n, ll m) +{ + ll x = n; + do + if (gcd(++x, n) == 1) m--; + while (m); + return x; +} +int main() +{ + ll T, k, m; + scanf("%lld", &T); + while (T--) + { + scanf("%lld%lld", &k, &m); + bool flag = true; + for (ll n = 1; n < 10000; n++) + if (((f(n, m) - n) ^ n) == k) + { + printf("%lld\n", n); + flag = false; + break; + } + if (flag) puts("-1"); + } + return 0; +} \ No newline at end of file diff --git a/hdu853/09.cpp b/hdu853/09.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/09.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/10.cpp b/hdu853/10.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/10.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/11.cpp b/hdu853/11.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/hdu853/11.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/hdu853/12.cpp b/hdu853/12.cpp new file mode 100644 index 0000000..31890b4 --- /dev/null +++ b/hdu853/12.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) +typedef long long ll, i64; +const int N = 1e5 + 50; +int a[N]; +int main() +{ + int T, n; + scanf("%d", &T); + while (T--) + { + scanf("%d", &n); + for (int i = 0; i < n; i++) scanf("%d", a + i); + sort(a, a + n, greater()); + ll cnt[] = {0, 0}; + for (int i = 0; i < n; i++) cnt[i & 1] += a[i]; + printf("%lld %lld\n", cnt[0], cnt[1]); + } + return 0; +} \ No newline at end of file diff --git a/hdu853/CMakeLists.txt b/hdu853/CMakeLists.txt new file mode 100644 index 0000000..ff9cee8 --- /dev/null +++ b/hdu853/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(01 01.cpp) +add_executable(02 02.cpp) +add_executable(03 03.cpp) +add_executable(04 04.cpp) +add_executable(05 05.cpp) +add_executable(06 06.cpp) +add_executable(07 07.cpp) +add_executable(08 08.cpp) +add_executable(09 09.cpp) +add_executable(10 10.cpp) +add_executable(11 11.cpp) +add_executable(12 12.cpp) diff --git a/nowcoder887/A.cpp b/nowcoder887/A.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/A.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/B.cpp b/nowcoder887/B.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/B.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/C.cpp b/nowcoder887/C.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/C.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/CMakeLists.txt b/nowcoder887/CMakeLists.txt new file mode 100644 index 0000000..766e4de --- /dev/null +++ b/nowcoder887/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(A A.cpp) +add_executable(B B.cpp) +add_executable(C C.cpp) +add_executable(D D.cpp) +add_executable(E E.cpp) +add_executable(F F.cpp) +add_executable(G G.cpp) +add_executable(H H.cpp) +add_executable(I I.cpp) +add_executable(J J.cpp) +add_executable(K K.cpp) diff --git a/nowcoder887/D.cpp b/nowcoder887/D.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/D.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/E b/nowcoder887/E new file mode 100644 index 0000000..a5e15b4 Binary files /dev/null and b/nowcoder887/E differ diff --git a/nowcoder887/E.cpp b/nowcoder887/E.cpp new file mode 100644 index 0000000..c62b38f --- /dev/null +++ b/nowcoder887/E.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 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; +const int N = 4e5 + 50; +int X[N], Y[N], mp[N << 1]; +template +struct SegTree +{ +#define L(x) ((x) << 1) +#define R(x) ((x) << 1 | 1) +#define avg(x, y) (((x) + (y)) >> 1) + struct Node + { + ll a, x; + } N[sz << 2]; + void addtag(int k, int l, int r, ll v) + { + N[k].a += v; + N[k].x += (r - l) * v; + } + void pushdown(int k, int l, int r) + { + if (N[k].a == 0) return; + int m = avg(l, r); + addtag(L(k), l, m, N[k].a); + addtag(R(k), m, r, N[k].a); + N[k].a = 0; + } + void modify(int k, int l, int r, int x, int y, ll v) + { + if (x <= l && r <= y) return addtag(k, l, r, v); + int m = avg(l, r); + pushdown(k, l, r); + if (x < m) modify(L(k), l, m, x, y, v); + if (y > m) modify(R(k), m, r, x, y, v); + N[k].x = N[L(k)].x + N[R(k)].x; + } + int kth(int k, int l, int r, int sz) + { + if (l == r - 1) + { + return l; + } + pushdown(k, l, r); + int d = N[L(k)].x, m = avg(l, r); + return d >= k ? kth(L(k), l, m, k) : kth(R(k), m, r, k - d); + } +}; +SegTree st; +int main() +{ + int n; + scanf("%d", &n); + { + ll a, b, c, m; + scanf("%d%d%lld%lld%lld%lld", X, X + 1, &a, &b, &c, &m); + for (int i = 2; i < n; i++) X[i] = (a * X[i - 1] + b * X[i - 2] + c) % m; + scanf("%d%d%lld%lld%lld%lld", Y, Y + 1, &a, &b, &c, &m); + for (int i = 2; i < n; i++) Y[i] = (a * Y[i - 1] + b * Y[i - 2] + c) % m; + for (int i = 0; i < n; i++) + { + if (X[i] > Y[i]) swap(X[i], Y[i]); + X[i]++, Y[i]++; + } + } + memcpy(mp, X, n << 2); + memcpy(mp + n, Y, n << 2); + sort(mp, mp + n + n); + int mpl = unique(mp, mp + n + n) - mp; + for (int i = 0; i < n; i++) X[i] = lower_bound(mp, mp + mpl, X[i]) - mp; + for (int i = 0; i < n; i++) Y[i] = lower_bound(mp, mp + mpl, Y[i]) - mp; + IFD + { + for (int i = 0; i < n; i++) printf("%d%c", mp[X[i]], " \n"[i == n - 1]); + for (int i = 0; i < n; i++) printf("%d%c", mp[Y[i]], " \n"[i == n - 1]); + } + for (int i = 0; i < n; i++) + { + } + return 0; +} \ No newline at end of file diff --git a/nowcoder887/F.cpp b/nowcoder887/F.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/F.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/G.cpp b/nowcoder887/G.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/G.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/H.cpp b/nowcoder887/H.cpp new file mode 100644 index 0000000..8e55521 --- /dev/null +++ b/nowcoder887/H.cpp @@ -0,0 +1,32 @@ +#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) +typedef long long ll, i64; +bitset<32> BM; +int main() +{ + int a, b, c; + while (~scanf("%d%d%d", &a, &b, &c)) + { + long long cnt[] = {0, 0, 0}; + for (int x = 1; x <= a; x++) + for (int y = 1; y <= b; y++) + { + if ((x & y) > c) cnt[0]++; + if ((x ^ y) < c) cnt[1]++; + if ((x & y) > c && (x ^ y) < c) cnt[2]++; + } + cout << (BM = a) << endl; + cout << (BM = b) << endl; + cout << (BM = c) << endl; + printf("%lld : %lld + %lld - %lld\n", cnt[0] + cnt[1] - cnt[2], cnt[0], cnt[1], cnt[2]); + } + return 0; +} \ No newline at end of file diff --git a/nowcoder887/I.cpp b/nowcoder887/I.cpp new file mode 100644 index 0000000..3ee04af --- /dev/null +++ b/nowcoder887/I.cpp @@ -0,0 +1,15 @@ +#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) +typedef long long ll, i64; +int main() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder887/J.cpp b/nowcoder887/J.cpp new file mode 100644 index 0000000..50ff33a --- /dev/null +++ b/nowcoder887/J.cpp @@ -0,0 +1,37 @@ +#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) +typedef long long ll, i64; +const int N = 1e5 + 50; +ll a[N], b[N], c[N]; +int main() +{ + int n, k; + scanf("%d%d", &n, &k); + for (int i = 0; i < n; i++) scanf("%lld%lld", a + i, b + i); + for (int i = 1; i < n; i++) c[i] = b[i - 1] * a[i]; + ll baseV = accumulate(c, c + n, 0ll); + ll mn = 0, mx = 0, mnt = 0, mxt = 0; + for (int i = 1; i < n; i++) + { + } + mn = min(mn, mnt), mx = max(mx, mxt); + if (k == 0) + printf("%lld", baseV); + else + { + ll cur = baseV; + ll minId = n; + for (int i = n; i; i--) { + } + printf("%lld", cur); + } + return 0; +} \ No newline at end of file diff --git a/nowcoder887/K.cpp b/nowcoder887/K.cpp new file mode 100644 index 0000000..b28f58d --- /dev/null +++ b/nowcoder887/K.cpp @@ -0,0 +1,45 @@ +#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) +typedef long long ll, i64; +const int N = 1e6 + 50; +bool vis[N]; +int a[N]; +void read(int &x) +{ + int ch = x = 0; + while (!isdigit(ch)) ch = getchar(); + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; +} +int main() +{ + int n, m, q; + read(n), read(m), read(q); + for (int i = 1; i <= n; i++) read(a[i]); + for (int i = 1, x, y; i < m; i++) + { + read(x), read(y); + if (x == y) continue; + vis[x] = true; + } + for (int i = 1; i <= n; i++) + { + if (vis[i]) a[i] = 0; + a[i] += a[i - 1]; + } + ll ans = 0; + for (int i = 1, x, y; i <= q; i++) + { + read(x), read(y); + ans ^= i * (a[y] - a[x - 1]); + } + printf("%lld", ans); + return 0; +} \ No newline at end of file diff --git a/nowcoder888/A.cpp b/nowcoder888/A.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder888/A.cpp @@ -0,0 +1,19 @@ +#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() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder888/B.cpp b/nowcoder888/B.cpp new file mode 100644 index 0000000..dd52cf5 --- /dev/null +++ b/nowcoder888/B.cpp @@ -0,0 +1,35 @@ +#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; +const int N = 1e5 + 50; +int n, a[N], cnt[N], last[N]; +int main() +{ + scanf("%d", &n); + for (int i = 1; i <= n; i++) scanf("%d", a + i); + ll ans = 0, cur = 0; + for (ll i = 1; i <= n; i++) + { + cur += cnt[i] = cnt[i - 1]; + if (last[a[i]] == 0) + cnt[i]++; + else + cur -= i - last[a[i]]; + last[a[i]] = i; + ans += i * cnt[i] - cur; + } + printf("%lld", ans); + return 0; +} \ No newline at end of file diff --git a/nowcoder888/C.cpp b/nowcoder888/C.cpp new file mode 100644 index 0000000..8503e70 --- /dev/null +++ b/nowcoder888/C.cpp @@ -0,0 +1,34 @@ +#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; +const int N = 1 << 10 | 1; +int a[N][N]; +int main() +{ + int n; + scanf("%d", &n); + a[0][0] = 1; + for (int c = 1; c < n; c <<= 1) + for (int i = 0; i < c; i++) + for (int j = 0; j < c; j++) + { + a[c + i][j] = a[i][c + j] = a[i][j]; + a[c + i][c + j] = a[i][j] ^ 1; + } + for (int i = 0; i < n; i++) + for (int j = 0; j < n; j++) + printf("%d%c", a[i][j] * 2 - 1, " \n"[j == n - 1]); + return 0; +} \ No newline at end of file diff --git a/nowcoder888/CMakeLists.txt b/nowcoder888/CMakeLists.txt new file mode 100644 index 0000000..45f29f4 --- /dev/null +++ b/nowcoder888/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.0) +set(CMAKE_CXX_STANDARD 17) +if(MSVC) + add_compile_options("/Zc:__cplusplus") +endif() +include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32") +add_executable(A A.cpp) +add_executable(B B.cpp) +add_executable(C C.cpp) +add_executable(D D.cpp) +add_executable(E E.cpp) +add_executable(F F.cpp) +add_executable(G G.cpp) +add_executable(H H.cpp) +add_executable(I I.cpp) +add_executable(J J.cpp) diff --git a/nowcoder888/D.cpp b/nowcoder888/D.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder888/D.cpp @@ -0,0 +1,19 @@ +#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() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder888/E.cpp b/nowcoder888/E.cpp new file mode 100644 index 0000000..2d50125 --- /dev/null +++ b/nowcoder888/E.cpp @@ -0,0 +1,48 @@ +#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; +const int N = 1e5 + 50; +struct Edge +{ + int nxt, to, l, r; +} E[N]; +int adj[N], ecnt; +inline void addEdge(int f, int t, int l, int r) +{ + E[++ecnt] = {adj[f], t, l, r}; + adj[f] = ecnt; +} +bool modify(int u, int v, int l, int r) +{ + return false; +} +int main() +{ + int n, m; + scanf("%d%d", &n, &m); + for (int i = 0, f, t, l, r; i < m; i++) + { + scanf("%d%d%d%d", &f, &t, &l, &r); + addEdge(f, t, l, r); + addEdge(t, f, l, r); + } + queue Q; + static bool inq[N]; + for (Q.push(1), inq[1] = true; !Q.empty(); inq[Q.front()] = false, Q.pop()) + for (int u, e = adj[u = Q.front()]; e; e = E[e].nxt) + if (modify(u, E[e].to, E[e].l, E[e].r) && !inq[E[e].to]) + Q.push(E[e].to), inq[E[e].to] = true; + return 0; +} \ No newline at end of file diff --git a/nowcoder888/F.cpp b/nowcoder888/F.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder888/F.cpp @@ -0,0 +1,19 @@ +#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() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder888/G.cpp b/nowcoder888/G.cpp new file mode 100644 index 0000000..0a8ae53 --- /dev/null +++ b/nowcoder888/G.cpp @@ -0,0 +1,53 @@ +#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; +const int N = 1e5 + 50; +char s[N]; +int main() +{ + scanf("%s", s); + int n = strlen(s), ans = 0; + list l(s, s + n); + for (auto ite = l.begin(); ite != l.end();) + { + bool flag = true; + auto ite2 = ite; + ++ite2; + if (ite2 != l.end() && *ite2 == *ite) + { + auto ite3 = ite2; + ++ite3; + if (ite3 != l.end() && *ite3 == *ite) + { + flag = false; + ans++; + if (ite == l.begin()) + { + l.erase(ite, ++ite3); + ite = l.begin(); + } + else + { + l.erase(ite--, ++ite3); + if (ite != l.begin()) --ite; + } + } + } + if (flag && ite != l.end()) + ++ite; + } + printf("%d", ans); + return 0; +} \ No newline at end of file diff --git a/nowcoder888/H.cpp b/nowcoder888/H.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder888/H.cpp @@ -0,0 +1,19 @@ +#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() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder888/I.cpp b/nowcoder888/I.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder888/I.cpp @@ -0,0 +1,19 @@ +#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() +{ + return 0; +} \ No newline at end of file diff --git a/nowcoder888/J.cpp b/nowcoder888/J.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder888/J.cpp @@ -0,0 +1,19 @@ +#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() +{ + return 0; +} \ No newline at end of file