diff --git a/hdu854/11.cpp b/hdu854/11.cpp index 3b03e9b..8ba9651 100644 --- a/hdu854/11.cpp +++ b/hdu854/11.cpp @@ -35,8 +35,8 @@ template inline typename enable_if::value>::type read(T &x) { int ch = x = 0; - while (!isdigit(ch)) ch = getchar(0); - for (; isdigit(ch); ch = getchar(0)) x = x * 10 + ch - '0'; + while (!isdigit(ch)) ch = getchar(); + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; } const int N = 5e5 + 50; ll r[N], s[N], x[N], a[N]; @@ -72,7 +72,7 @@ struct frac printf("%lld\n", ll(h * inv(l) % mod)); } }; -frac psum[N]; +ll psum[N]; int main() { int T, n, q; @@ -81,13 +81,17 @@ int main() { read(n), read(q); for (int i = 1; i <= n; i++) read(r[i]), read(s[i]), read(x[i]), read(a[i]); - psum[0] = psum[1] = {0, 1}; + /*psum[0] = psum[1] = {0, 1}; for (int i = 1; i <= n; i++) psum[i + 1] = psum[i] + frac{a[i], 1} * frac{s[i], r[i]} + (psum[i] - psum[x[i]]) * frac{s[i] - r[i], r[i]}; for (int i = 1, l, r; i <= q; i++) - read(l), read(r), (psum[r] - psum[l]).print(); + read(l), read(r), (psum[r] - psum[l]).print();*/ + for (int i = 1; i <= n; i++) + psum[i + 1] = (psum[i] + (a[i] * s[i] + (s[i] - r[i]) * (psum[i] - psum[x[i]] + mod)) % mod * inv(r[i])) % mod; + for (int i = 1, l, r; i <= q; i++) + read(l), read(r), printf("%lld\n", (psum[r] - psum[l] + mod) % mod); } return 0; } \ No newline at end of file diff --git a/hdu855/01.cpp b/hdu855/01.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/01.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/hdu855/02.cpp b/hdu855/02.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/02.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/hdu855/03.cpp b/hdu855/03.cpp new file mode 100644 index 0000000..83f2461 --- /dev/null +++ b/hdu855/03.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; +int f(int d, int n) +{ + int cnt = 0; + for (int i = 1; i <= n; i++) + for (int x = i; x; x /= 10) + if (x % 10 == d) cnt++; + return cnt; +} +int main() +{ + for (int k = 1; k < 10; k++) + for (int i = 199900; i < 200100; i++) + if (f(k, i) == i) + printf("%d %d\n", k, i); + return 0; + for (int d, n; ~scanf("%d%d", &d, &n);) + printf("%d\n", f(d, n)); + return 0; +} \ No newline at end of file diff --git a/hdu855/04.cpp b/hdu855/04.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/04.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/hdu855/05.cpp b/hdu855/05.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/05.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/hdu855/06.cpp b/hdu855/06.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/06.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/hdu855/07.cpp b/hdu855/07.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/07.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/hdu855/08.cpp b/hdu855/08.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/08.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/hdu855/09.cpp b/hdu855/09.cpp new file mode 100644 index 0000000..4247558 --- /dev/null +++ b/hdu855/09.cpp @@ -0,0 +1,58 @@ +#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; +bool mp[20][20]; +int d[4][2] = {{1, 0}, {0, -1}, {-1, 0}, {0, 1}}; +void fil(int x, int y) +{ + mp[x][y] = true; + for (int i = 0; i < 4; i++) + if (!mp[x + d[i][0]][y + d[i][1]]) + fil(x + d[i][0], y + d[i][1]); +} +int main() +{ + int T, x11, y11, x12, y12, x21, y21, x22, y22; + scanf("%d", &T); + while (T--) + { + scanf("%d%d%d%d%d%d%d%d", &x11, &y11, &x12, &y12, &x21, &y21, &x22, &y22); + int a[] = {x11, y11, x12, y12, x21, y21, x22, y22}; + sort(a, a + 8); + int l = unique(a, a + 8) - a; + x11 = (lower_bound(a, a + l, x11) - a + 1) << 1; + y11 = (lower_bound(a, a + l, y11) - a + 1) << 1; + x12 = (lower_bound(a, a + l, x12) - a + 1) << 1; + y12 = (lower_bound(a, a + l, y12) - a + 1) << 1; + x21 = (lower_bound(a, a + l, x21) - a + 1) << 1; + y21 = (lower_bound(a, a + l, y21) - a + 1) << 1; + x22 = (lower_bound(a, a + l, x22) - a + 1) << 1; + y22 = (lower_bound(a, a + l, y22) - a + 1) << 1; + CLR(mp); + for (int i = x11; i <= x12; i++) mp[i][y11] = mp[i][y12] = true; + for (int i = y11; i <= y12; i++) mp[x11][i] = mp[x12][i] = true; + for (int i = x21; i <= x22; i++) mp[i][y21] = mp[i][y22] = true; + for (int i = y21; i <= y22; i++) mp[x21][i] = mp[x22][i] = true; + for (int i = 0; i < 20; i++) + mp[0][i] = mp[19][i] = mp[i][0] = mp[i][19] = true; + int cnt = 0; + for (int i = 0; i < 20; i++) + for (int j = 0; j < 20; j++) + if (!mp[i][j]) + fil(i, j), cnt++; + printf("%d\n", cnt); + } + return 0; +} \ No newline at end of file diff --git a/hdu855/10.cpp b/hdu855/10.cpp new file mode 100644 index 0000000..100a706 --- /dev/null +++ b/hdu855/10.cpp @@ -0,0 +1,42 @@ +#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][12]; +struct rec +{ + int s, p, t; + OPL(rec, rhs) + { + return p > rhs.p || (p == rhs.p && t < rhs.t); + } +} recs[N]; +int main() +{ + int T, n, d; + scanf("%d", &T); + while (T--) + { + scanf("%d%d", &n, &d); + for (int i = 0; i < n; i++) + scanf("%s%d%d", s + i, &recs[i].p, &recs[i].t), recs[i].s = i; + sort(recs, recs + n); + if (n * d % 10 == 5) + puts(s[recs[n * d / 10].s]); + else + puts("Quailty is very great"); + } + return 0; +} \ No newline at end of file diff --git a/hdu855/11.cpp b/hdu855/11.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu855/11.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/hdu855/CMakeLists.txt b/hdu855/CMakeLists.txt new file mode 100644 index 0000000..6448c86 --- /dev/null +++ b/hdu855/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.2.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) diff --git a/hdu857/01.cpp b/hdu857/01.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/01.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/hdu857/02.cpp b/hdu857/02.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/02.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/hdu857/03.cpp b/hdu857/03.cpp new file mode 100644 index 0000000..6212902 --- /dev/null +++ b/hdu857/03.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); + double mx = 0, cur; + for (int i = 0; i < n; i++) scanf("%lf", &cur), mx = max(mx, cur); + printf("%.12lf\n", mx); + } + return 0; +} \ No newline at end of file diff --git a/hdu857/04.cpp b/hdu857/04.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/04.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/hdu857/05.cpp b/hdu857/05.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/05.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/hdu857/06.cpp b/hdu857/06.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/06.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/hdu857/07.cpp b/hdu857/07.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/07.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/hdu857/08.cpp b/hdu857/08.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/08.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/hdu857/09.cpp b/hdu857/09.cpp new file mode 100644 index 0000000..9cc6ac8 --- /dev/null +++ b/hdu857/09.cpp @@ -0,0 +1,77 @@ +#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 = 2050; +int blk[N][N]; +inline bool unstable(int x, int y, int t) +{ + return (blk[x - 1][y] == t || blk[x + 1][y] == t) && (blk[x][y - 1] == t || blk[x][y + 1] == t); +} +struct +{ + int x, y; +} que[N * N]; +int dx[] = {1, 0, -1, 0}; +int dy[] = {0, 1, 0, -1}; +inline void read(int &x) +{ + int ch = x = 0; + while (!isdigit(ch)) ch = getchar(); + for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; +} +int Tt, T, n, m, q; +int dfs(int x, int y) +{ + int ans = 1; + blk[x][y] = Tt; + for (int i = 0; i < 4; i++) + { + x += dx[i], y += dy[i]; + if (x >= 1 && x <= n && y >= 1 && y <= m && blk[x][y] != Tt && unstable(x, y, Tt)) + ans += dfs(x, y); + x -= dx[i], y -= dy[i]; + } + return ans; +} +int main() +{ + read(T); + for (int t = 1; t <= T; t++) + { + Tt = t; + read(n), read(m), read(q); + for (int x, y, len; q-- && (read(x), read(y), 1);) + if (blk[x][y] == t) + puts("0"); + else + { + /*len = 0, que[len++] = {x, y}; + for (int h = 0; h < len; h++) + { + auto cur = que[h]; + blk[cur.x][cur.y] = t; + for (int i = 0; i < 4; i++) + { + cur.x += dx[i], cur.y += dy[i]; + if (cur.x >= 1 && cur.x <= n && cur.y >= 1 && cur.y <= m && blk[cur.x][cur.y] != t && unstable(cur.x, cur.y, t)) + que[len++] = cur; + cur.x -= dx[i], cur.y -= dy[i]; + } + }*/ + printf("%d\n", dfs(x, y)); + } + } + return 0; +} \ No newline at end of file diff --git a/hdu857/10.cpp b/hdu857/10.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/10.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/hdu857/11.cpp b/hdu857/11.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/hdu857/11.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/hdu857/CMakeLists.txt b/hdu857/CMakeLists.txt new file mode 100644 index 0000000..6448c86 --- /dev/null +++ b/hdu857/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.2.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) diff --git a/nowcoder889/A.cpp b/nowcoder889/A.cpp new file mode 100644 index 0000000..a502810 --- /dev/null +++ b/nowcoder889/A.cpp @@ -0,0 +1,20 @@ +#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() +{ + vector v; + return 0; +} \ No newline at end of file diff --git a/nowcoder889/B.cpp b/nowcoder889/B.cpp new file mode 100644 index 0000000..732c5f8 --- /dev/null +++ b/nowcoder889/B.cpp @@ -0,0 +1,36 @@ +#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; + scanf("%d", &T); + ll b, c, p = 1e9 + 7; + while (T--) + { + scanf("%lld%lld", &b, &c); + bool flag = true; + for (ll i = 0; i < 10000000 && flag; i++) + if ((b * b - 4 * c - i * i) % (4 * p) == 0) + if ((b + i) & 1 ^ 1) + printf("%lld %lld\n", (b - i) >> 1, (b + i) >> 1), flag = false; + for (ll i = 0; i < 10000000 && flag; i++) + if (((p + b) * (p + b) - 4 * c) % (4 * p) == 0) + if ((p + b + i) & 1 ^ 1) + printf("%lld %lld\n", (p + b - i) >> 1, (p + b + i) >> 1), flag = false; + if (flag) puts("-1 -1"); + } + return 0; +} \ No newline at end of file diff --git a/nowcoder889/C.cpp b/nowcoder889/C.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/C.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/nowcoder889/CMakeLists.txt b/nowcoder889/CMakeLists.txt new file mode 100644 index 0000000..5592e15 --- /dev/null +++ b/nowcoder889/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.2.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/nowcoder889/D.cpp b/nowcoder889/D.cpp new file mode 100644 index 0000000..c8d21f8 --- /dev/null +++ b/nowcoder889/D.cpp @@ -0,0 +1,67 @@ +#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 a[40], n, s, rs; +int main() +{ + scanf("%lld%lld", &n, &s); + for (int i = 0; i < n; i++) scanf("%lld", a + i); + int thr = 18; + if (n <= thr) + { + for (int i = 0; i < (1 << n); i++) + { + ll sum = 0; + for (int j = 0; j < n; j++) + if (i >> j & 1) + sum += a[j]; + if (sum == s) + { + for (int j = 0; j < n; j++) + putchar('0' + (i >> j & 1)); + exit(0); + } + } + } + else + { + unordered_map M; + for (int i = 0; i < (1 << thr); i++) + { + ll sum = 0; + for (int j = 0; j < thr; j++) + if (i >> j & 1) + sum += a[j]; + M[sum] = i; + } + for (int i = 0; i < (1 << (n - thr)); i++) + { + ll sum = 0; + for (int j = thr; j < n; j++) + if (i >> (j - thr) & 1) + sum += a[j]; + auto ite = M.find(s - sum); + if (ite != M.end()) + { + for (int j = 0; j < thr; j++) + putchar('0' + (ite->second >> j & 1)); + for (int j = thr; j < n; j++) + putchar('0' + (i >> (j - thr) & 1)); + exit(0); + } + } + } + return 0; +} \ No newline at end of file diff --git a/nowcoder889/E.cpp b/nowcoder889/E.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/E.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/nowcoder889/F.cpp b/nowcoder889/F.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/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/nowcoder889/G.cpp b/nowcoder889/G.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/G.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/nowcoder889/H.cpp b/nowcoder889/H.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/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/nowcoder889/I.cpp b/nowcoder889/I.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/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/nowcoder889/J.cpp b/nowcoder889/J.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/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 diff --git a/nowcoder889/K.cpp b/nowcoder889/K.cpp new file mode 100644 index 0000000..21a092b --- /dev/null +++ b/nowcoder889/K.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