Thu, 24 Oct 2019 14:17:41 +0800

master
大蒟蒻 6 years ago
parent 70e024b43b
commit 8edf1c1642

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.0)
project(337053)
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)
add_executable(L L.cpp)
add_executable(M M.cpp)

@ -0,0 +1,44 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
constexpr double eps = 1e-8;
struct p
{
double x, y, z;
} a[105];
int n;
inline double dis2(CRP(p, a), CRP(p, b))
{
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z);
}
int main()
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].z);
double ans = 1e30;
p z{0};
for (double step = 10000; step > eps; step *= 0.98)
{
p s = *max_element(a, a + n, [&z](CRP(p, a), CRP(p, b)) { return dis2(z, a) < dis2(z, b); });
double mx = sqrt(dis2(z, s));
ans = min(ans, mx);
z.x += (s.x - z.x) / mx * step;
z.y += (s.y - z.y) / mx * step;
z.z += (s.z - z.z) / mx * step;
}
printf("%.15lf\n", ans);
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,24 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 ll mod = 1e9 + 7;
int main()
{
ll n, T;
scanf("%lld", &T);
while (T--)
scanf("%lld", &n), printf("%lld\n", n * (n + 1) % mod * (n + 2) % mod * (n + 3) % mod * 41666667 % mod);
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,94 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
inline void read(int &x)
{
int ch = x = 0;
while (!isdigit(ch = getchar()))
;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
}
const int N = 505 * 505, inf = 0x3f3f3f3f;
int adj[N], nxt[N << 1], to[N << 1], cap[N << 1], cur[N], cnt[N], dis2[N], fa[N], ecnt;
inline void addEdge_impl_(int f, int t, int c)
{
nxt[ecnt] = adj[f];
adj[f] = ecnt;
to[ecnt] = t;
cap[ecnt] = c;
ecnt++;
}
inline void addEdge(int f, int t, int c)
{
addEdge_impl_(f, t, c);
addEdge_impl_(t, f, 0);
}
int ISAP(int S, int T)
{
int flow = 0;
for (int i = 0; i < N; i++) dis2[i] = N - 1;
int len = 0, x;
static int que[N];
dis2[que[len++] = T] = 0;
for (int i = 0; i < len; i++)
for (int e = adj[x = que[i]]; ~e; e = nxt[e])
if (cap[e ^ 1] && dis2[to[e]] > dis2[x] + 1)
dis2[que[len++] = to[e]] = dis2[x] + 1;
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i < N; i++) cur[i] = adj[i], cnt[dis2[i]]++;
x = S;
while (dis2[S] < N - 1)
{
if (x == T)
{
int curFlow = inf;
for (x = T; x != S; x = to[fa[x] ^ 1]) curFlow = min(curFlow, cap[fa[x]]);
for (x = T; x != S; x = to[fa[x] ^ 1]) cap[fa[x]] -= curFlow, cap[fa[x] ^ 1] += curFlow;
flow += curFlow, x = S;
}
bool needRetreat = true;
for (int e = cur[x]; needRetreat && ~e; e = nxt[e])
if (cur[x] = e, cap[e] && dis2[x] == dis2[to[e]] + 1)
needRetreat = false, fa[x = to[e]] = e;
if (needRetreat)
{
int nd = N - 2;
for (int e = adj[x]; ~e; e = nxt[e])
if (cap[e]) nd = min(nd, dis2[to[e]]);
if (--cnt[dis2[x]] == 0) break;
++cnt[dis2[x] = nd + 1];
cur[x] = adj[x];
if (x != S) x = to[fa[x] ^ 1];
}
}
return flow;
}
int sm[N];
int main()
{
int n, m, k;
read(n), read(m), read(k);
NE1(adj), ecnt = 0;
addEdge(0, n + m + 1, k);
for (int i = 1, cnt; i <= n; i++)
{
read(cnt), addEdge(0, i, 1), addEdge(n + m + 1, i, 1);
for (int j = 0, x; j < cnt; j++)
read(x), addEdge(i, n + x, 1);
}
for (int i = 1; i <= m; i++) addEdge(n + i, n + m + 2, 1);
printf("%d\n", ISAP(0, n + m + 2));
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,29 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 1050;
int main()
{
int n, x;
scanf("%d", &n);
ll cnt = 0;
while (n--)
{
scanf("%d", &x);
for (; x & 1 ^ 1; x >>= 1) cnt++;
}
printf("%lld", cnt);
return 0;
}

@ -0,0 +1,37 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 1050;
ll a[N], b[N], c[N], id[N];
int main()
{
ll ans = 0;
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%lld%lld%lld", a + i, b + i, c + i), id[i] = i;
for (int i : {-1, 1})
for (int j : {-1, 1})
for (int k : {-1, 1})
{
sort(id, id + n, [&](ll l, ll r) {
return i * a[l] + j * b[l] + k * c[l] > i * a[r] + j * b[r] + k * c[r];
});
ans = max(ans, accumulate(id, id + m, 0ll, [&](ll pre, int cur) {
return pre + i * a[cur] + j * b[cur] + k * c[cur];
}));
}
printf("%lld", ans);
return 0;
}

@ -0,0 +1,23 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 1e6 + 60;
int main()
{
int n, k;
scanf("%d%d", &n, &k);
printf("%d", (n - 1 + k - 2) / (k - 1));
return 0;
}

@ -0,0 +1,35 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 1e6 + 60;
int sum(ll x)
{
int r = 0;
for (; x; x /= 10) r += x % 10;
return r;
}
int main()
{
int k;
scanf("%d", &k);
ll ans = 0, x = 1;
for (int i = 0; i < k; i++)
{
while ((ans + x) * sum(ans + x * 10) >= (ans + x * 10) * sum(ans + x)) x *= 10;
ans += x;
printf("%lld\n", ans);
}
return 0;
}

@ -0,0 +1,26 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 2e5 + 60;
ll a[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", a + i), a[i] -= i;
nth_element(a, a + n / 2, a + n);
printf("%lld", accumulate(a, a + n, 0ll, [&](ll s, ll c) { return s + abs(c - a[n >> 1]); }));
return 0;
}

@ -0,0 +1,40 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 2e5 + 60;
ll a[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%lld", a + i), a[i] += a[i - 1];
ll ans = numeric_limits<decltype(ans)>::max();
for (int i = 2; i < n - 1; i++)
{
int sp1 = lower_bound(a, a + n + 1, a[i] >> 1) - a;
int sp2 = lower_bound(a, a + n + 1, (a[n] + a[i]) >> 1) - a;
for (int j = -1; j <= 1; j++)
for (int k = -1; k <= 1; k++)
{
int sp3 = max(min(sp1 + j, i - 1), 1);
int sp4 = max(min(sp2 + k, n - 1), i + 1);
auto res = {a[sp3], a[i] - a[sp3], a[sp4] - a[i], a[n] - a[sp4]};
//printf("%d %d %d %lld\n", sp3, i, sp4, max(res) - min(res));
ans = min(ans, max(res) - min(res));
}
}
printf("%lld", ans);
return 0;
}

@ -0,0 +1,24 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 2e5 + 60;
int a[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", a + i);
return 0;
}

@ -0,0 +1,36 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 205;
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), a[i]--;
int st = *a;
bool flag = true;
for (int i = 1; i < n; i++)
if ((a[i - 1] + 1) % n != a[i]) flag = false;
if (!flag)
for (int i = flag = 1; i < n; i++)
if ((a[i - 1] + n - 1) % n != a[i]) flag = false;
puts(flag ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,35 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 a[405];
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n), n <<= 2;
for (int i = 0; i < n; i++) scanf("%d", a + i);
sort(a, a + n);
bool flag = true;
for (int i = 0; i < n && flag; i += 2)
if (a[i] != a[i + 1]) flag = false;
int ans = a[0] * a[n - 1];
for (int i = 0; i + i < n && flag; i++)
if (a[i] * a[n - i - 1] != ans) flag = false;
puts(flag ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,41 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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); }
const int N = 4e5 + 50, M = 1e6 + 60;
ll a[N];
int primes[N], pcnt;
bool notPrime[M];
int main()
{
for (ll i = 2; i < M; i++)
if (!notPrime[i] && (primes[pcnt++] = i))
for (ll j = i * i; j < M; j += i)
notPrime[j] = true;
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", a + i);
ll g = *a;
for (int i = 1; i < n; i++) g = gcd(g, a[i]);
ll ans = 1, cur = 0;
for (int i = 0; i < pcnt && g > 1; i++)
{
cur = 0;
for (; g % primes[i] == 0; g /= primes[i]) cur++;
ans *= cur + 1;
}
printf("%lld", ans);
return 0;
}

@ -0,0 +1,14 @@
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(D1 D1.cpp)
add_executable(D2 D2.cpp)
add_executable(E E.cpp)
add_executable(F1 F1.cpp)
add_executable(F2 F2.cpp)

@ -0,0 +1,38 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 is_subseq(string s, CRP(string, t))
{
int lastPos = 0;
for (auto ch : t)
{
lastPos = s.find(ch, lastPos);
if (lastPos == string::npos) return false;
lastPos++;
}
return true;
}
int main()
{
int ans = 0;
string s, t;
cin >> s >> t;
for (int i = 0; i <= s.size(); i++)
for (int j = i + ans; j <= s.size(); j++)
if (is_subseq(s.substr(0, i) + s.substr(j), t))
ans = max(ans, j - i);
cout << ans;
return 0;
}

@ -0,0 +1,33 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 2e5 + 50;
int a1[N], a2[N];
int main()
{
string s, t;
cin >> s >> t;
a1[0] = -1, a2[t.size()] = s.size();
for (int i = 0; i < t.size(); i++)
a1[i + 1] = s.find(t[i], a1[i] + 1);
for (int i = t.size() - 1; i >= 0; i--)
a2[i + 1] = s.rfind(t[i], a2[i + 2] - 1);
int ans = max<int>(s.size() - a1[t.size()] - 1, a2[1]);
for (int i = 2; i <= t.size(); i++) ans = max(ans, max(a1[i] - a1[i - 1], a2[i] - a2[i - 1]) - 1);
for (int i = 1; i <= t.size(); i++) ans = max(ans, a2[i] - a1[i]);
for (int i = 2; i <= t.size(); i++) ans = max(ans, a2[i] - a1[i - 1] - 1);
cout << ans;
return 0;
}

@ -0,0 +1,34 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 15e4 + 50;
int a[N];
bool b[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
sort(a, a + n);
for (int i = 0; i < n; i++)
if (a[i] > 1 && !b[a[i] - 1])
b[a[i] - 1] = true;
else if (!b[a[i]])
b[a[i]] = true;
else if (!b[a[i] + 1])
b[a[i] + 1] = true;
printf("%d", accumulate(b, b + N, 0));
return 0;
}

@ -0,0 +1,40 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 105;
ll a[N], b[N];
bool done[N];
int main()
{
ll n, r;
scanf("%lld%lld", &n, &r);
for (int i = 0; i < n; i++) scanf("%lld%lld", a + i, b + i);
for (int j = 0; j < n; j++)
{
ll id = -1, cur = INT_MIN, cur2 = INT_MIN;
for (int i = 0; i < n; i++)
if (!done[i] && a[i] <= r && b[i] > cur)
cur = b[id = i];
if (id == -1) return puts("NO"), 0;
if (cur < 0)
for (int i = 0; i < n; i++)
if (!done[i] && a[i] <= r && (a[i] > cur || (a[i] == cur && b[i] > cur2)))
id = i, cur = a[i], cur2 = b[i];
r += b[id], done[id] = true;
if (r < 0) return puts("NO"), 0;
}
puts("YES");
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,32 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 l, r;
scanf("%d%d", &l, &r);
for (int i = l; i <= r; i++)
{
char s[20];
sprintf(s, "%d", i);
bool flag = true;
for (int i = 0; s[i]; i++)
for (int j = 0; j < i; j++)
if (s[j] == s[i]) flag = false;
if (flag) return puts(s), 0;
}
puts("-1");
return 0;
}

@ -0,0 +1,49 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 1050, mod = 1e9 + 7;
int a[N][N], r[N], c[N];
void trySet(int i, int j, int v)
{
if (a[i][j] != 0 && a[i][j] != v) puts("0"), exit(0);
a[i][j] = v;
}
int main()
{
int h, w;
scanf("%d%d", &h, &w);
for (int i = 0; i < h; i++) scanf("%d", r + i);
for (int i = 0; i < w; i++) scanf("%d", c + i);
for (int i = 0; i < h; i++)
{
for (int j = 0; j < r[i]; j++)
trySet(i, j, 2);
trySet(i, r[i], 1);
}
for (int i = 0; i < w; i++)
{
for (int j = 0; j < c[i]; j++)
trySet(j, i, 2);
trySet(c[i], i, 1);
}
int zcnt = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (a[i][j] == 0) zcnt++;
long long ans = 1;
for (int i = 0; i < zcnt; i++) ans = ans * 2 % mod;
printf("%lld", ans);
return 0;
}

@ -0,0 +1,79 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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, mod = 1e9 + 7;
bool notPrime[N];
int primes[N], pcnt;
ll g(ll x, ll p)
{
ll xx = x;
if (p == 1) return 1;
ll r = 1;
while (x % r == 0) r = r * p % mod;
if (r / p > 1) printf("g(%lld, %lld)\n", xx, p);
return r / p;
}
ll f(ll x, ll y)
{
ll r = 1;
for (int i = 0; i < pcnt && x >= primes[pcnt]; i++)
if (x % primes[i] == 0)
{
r = r * g(y, primes[i]) % mod;
while (x % primes[i] == 0) x /= primes[i];
}
if (x != 1) r = r * g(y, x) % mod;
return r;
}
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;
}
int main()
{
for (ll i = 2; i < N; i++)
if (!notPrime[i])
for (ll j = (primes[pcnt++] = i, i * i); j < N; j += i)
notPrime[j] = true;
ll x, n;
cin >> x >> n;
ll xx = x;
vector<ll> v;
for (int i = 0; i < pcnt && x >= primes[pcnt]; i++)
if (x % primes[i] == 0)
{
v.push_back(primes[i]);
while (x % primes[i] == 0) x /= primes[i];
}
if (x != 1) v.push_back(x);
x = xx;
/*ll ansp = 1;
for (ll i = 1; i <= n; i++) ansp = ansp * f(x, i) % mod;
cout << ansp << endl;*/
ll ans = 1;
for (ll p : v)
{
ll cur = 1, tmp = 1;
while (n / p >= cur)
cur = cur * p, tmp = fpow(p, n / cur) * tmp % mod;
ans = ans * tmp % mod;
}
cout << ans;
return 0;
}

@ -0,0 +1,12 @@
project(cf1228)
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)

@ -0,0 +1,55 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 3e5 + 50;
vector<int> V[N];
int inSet[N];
set<int> s[10];
bool check(set<int> &s1, set<int> &s2)
{
return true;
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0, x, y; i < m; i++)
scanf("%d%d", &x, &y), V[x].push_back(y), V[y].push_back(x);
for (int i = 1; i <= n; i++) V[i].push_back(0), V[i].push_back(n + 1), sort(V[i].begin(), V[i].end());
int scnt = 0;
for (int i = 1; i <= n; i++)
if (!inSet[i])
{
auto &S = s[scnt++];
auto &v = V[i];
if (scnt > 3) return puts("-1"), 0;
for (int i = 1; i < v.size(); i++)
for (int j = v[i - 1] + 1; j < v[i]; j++)
S.insert(j), inSet[j] = scnt;
}
if (scnt != 3) return puts("-1"), 0;
if (s[0].size() * s[1].size() + s[1].size() * s[2].size() + s[2].size() * s[0].size() != m) return puts("-1"), 0;
for (int i = 0; i < 3; i++)
for (int x : s[i])
for (int k = 1; k < V[x].size() - 1; k++)
if (inSet[V[x][k]] == i + 1)
return puts("-1"), 0;
/*if (check(s[0], s[1]) && check(s[1], s[2]) && check(s[2], s[0]))
for (int i = 1; i <= n; i++) printf("%d%c", inSet[i], " \n"[i == n]);
else
puts("-1");*/
for (int i = 1; i <= n; i++) printf("%d%c", inSet[i], " \n"[i == n]);
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,29 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 n, q;
scanf("%d", &q);
while (q--)
{
scanf("%d", &n);
if (n < 4)
printf("%d\n", 4 - n);
else
printf("%d\n", n & 1);
}
return 0;
}

@ -0,0 +1,36 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 105;
char s[N], t[N];
int cnt1[26], cnt2[26];
int main()
{
int n;
scanf("%d", &n);
while (n--)
{
scanf("%s%s", s, t);
CLR(cnt1), CLR(cnt2);
for (char *p = s; *p; p++) cnt1[*p - 'a']++;
for (char *p = t; *p; p++) cnt2[*p - 'a']++;
bool flag = false;
for (int i = 0; i < 26; i++)
if (cnt1[i] && cnt2[i])
flag = true;
puts(flag ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,71 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 2e5 + 50;
int p[N];
ll Q, n, X, A, Y, B, K;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
bool check(int len)
{
if (len <= 0) return true;
int ccnt = len / lcm(A, B);
int acnt = len / A - ccnt;
int bcnt = len / B - ccnt;
ll ans = -1, tmp = 0;
len = min(len, ccnt + acnt + bcnt);
for (int i = 0; i < len; i++)
{
if (i < ccnt)
tmp += p[i] * (X + Y);
else if (i < ccnt + acnt)
tmp += p[i] * X;
else if (i < ccnt + acnt + bcnt)
tmp += p[i] * Y;
if (tmp >= K)
{
ans = i + 1;
break;
}
}
return ans == -1;
}
int main()
{
scanf("%lld", &Q);
while (Q--)
{
scanf("%lld", &n);
for (int i = 0; i < n; i++) scanf("%d", p + i), p[i] /= 100;
scanf("%lld%lld%lld%lld%lld", &X, &A, &Y, &B, &K);
if (X < Y) swap(A, B), swap(X, Y);
sort(p, p + n, greater<int>());
if (check(n))
puts("-1");
else
{
int L = 0, R = n + 1, M;
while (R - L > 1)
if (check(M = (L + R) >> 1))
L = M;
else
R = M;
M = L;
if (check(M)) M = R;
printf("%d\n", M);
}
}
return 0;
}

@ -0,0 +1,84 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 3e5 + 50;
int a[N], cnt[N][2], b[N];
int ans[N][2];
int q, n;
int C[N];
bool vis[N];
int lst[N];
inline int lowbit(int x) { return x & -x; }
void inc(int x, int v = 1)
{
if (x > 0)
for (; x <= n; x += lowbit(x)) C[x] += v;
}
int sum(int x)
{
int r = 0;
if (x > 0)
for (; x; x -= lowbit(x)) r += C[x];
return r;
}
int main()
{
scanf("%d", &q);
while (q--)
{
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
n = unique(a, a + n) - a;
memset(cnt, 0, (n + 1) << 3);
memset(ans, 0, (n + 1) << 3);
memset(lst, 0, (n + 1) << 2);
memcpy(b, a, n << 2);
sort(b, b + n);
int lb = unique(b, b + n) - b;
for (int i = 0; i < n; i++) a[i] = lower_bound(b, b + lb, a[i]) - b + 1;
memset(C, 0, (n + 1) << 2);
memset(vis, 0, (n + 1));
for (int i = 0, dif = 0; i < n; i++)
{
inc(lst[a[i]], -1),
lst[a[i]] = i;
cnt[i][0] = dif - sum(a[i]);
if (!vis[a[i]])
{
//inc(a[i]);
vis[a[i]] = true;
dif++;
}
}
memset(C, 0, (n + 1) << 2);
memset(vis, 0, (n + 1));
for (int i = n - 1; i >= 0; i--)
{
cnt[i][1] = sum(a[i] - 1);
if (!vis[a[i]])
{
inc(a[i]);
vis[a[i]] = true;
}
}
IFD
{
for (int i = 0; i < n; i++) printf("%d%c", a[i], " \n"[i == n - 1]);
for (int i = 0; i < n; i++) printf("%d%c", cnt[i][0], " \n"[i == n - 1]);
for (int i = 0; i < n; i++) printf("%d%c", cnt[i][1], " \n"[i == n - 1]);
}
}
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,14 @@
project(cf1241)
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(1 1.cpp)
add_executable(2 2.cpp)
add_executable(3 3.cpp)
add_executable(4 4.cpp)
add_executable(5 5.cpp)
add_executable(6 6.cpp)
add_executable(7 7.cpp)

@ -0,0 +1,44 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 ll mod = 1e9 + 7;
const int N = 1e6 + 50;
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 _2[N];
ll calc(int n, int k)
{
if (n == 1) return _2[k];
if (n == 2) return _2[k] * (_2[k] - 1) % mod;
return (_2[k] * (_2[k] - 2) % mod * fpow(_2[k] - 1, n - 2) + calc(n - 2, k)) % mod;
}
int main()
{
for (int i = *_2 = 1; i < N; i++) _2[i] = (_2[i - 1] << 1) % mod;
int T, n, k;
scanf("%d", &T);
while (T--)
{
scanf("%d%d", &n, &k);
printf("%lld\n", calc(n, k));
}
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
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)
add_executable(L L.cpp)
add_executable(M M.cpp)

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,39 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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()
{
map<pair<int, int>, int> mp1, mp2;
int T, n, k, ans;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
mp1.clear(), mp2.clear(), ans = 0;
for (int i = 1; i <= n; i++)
{
pair<int, int> p;
scanf("%d", &k);
for (int j = 1; j <= k; j++)
{
scanf("%d%d", &p.first, &p.second);
if (mp1[p] < i) ans = max(ans, mp2[p]), mp2[p] = 0;
mp1[p] = i, mp2[p]++;
}
}
printf("%d\n", ans);
}
return 0;
}

@ -0,0 +1,33 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 50050;
int x[N], y[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d%d", x + i, y + i);
ll ans = 0;
set<int> S;
S.clear(), S.insert(0);
for (int i = n; i; S.insert(x[i--]))
ans += x[i] - *--S.lower_bound(x[i]);
S.clear(), S.insert(0);
for (int i = n; i; S.insert(y[i--]))
ans += y[i] - *--S.lower_bound(y[i]);
printf("%lld", ans);
return 0;
}

@ -0,0 +1,63 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
ll A[N], B[N];
inline ll lowbit(ll x) { return x & -x; }
template <ll *arr>
void update(ll p, ll v)
{
for (; p < N; p += lowbit(p))
arr[p] += v;
}
template <ll *arr>
ll query(ll p)
{
ll ans = 0;
for (; p; p -= lowbit(p))
ans += arr[p];
return ans;
}
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
{
begin(A);
ll tmp;
scanf("%lld", &tmp);
update<A>(i, tmp);
update<B>(i, tmp * (N - i + 1));
}
for (int i = 1; i <= m; i++)
{
ll op, x, y;
scanf("%lld%lld%lld", &op, &x, &y);
if (op == 1)
{
ll ans1 = query<B>(y) - query<B>(x - 1);
ll ans2 = query<A>(y) - query<A>(x - 1);
printf("%lld\n", ans1 - ans2 * (N - y));
}
else
{
ll dif = query<A>(x) - query<A>(x - 1);
update<A>(x, y - dif);
update<B>(x, (y - dif) * (N - x + 1));
}
}
return 0;
}

@ -0,0 +1,35 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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 = 1e6 + 60;
char s[N], p[3];
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
int ans = 1;
scanf("%d%s%s", &n, p, s);
for (int i = 0; i < n; i++)
if (s[i] != *p)
{
ans = ((n - i) << 1) - (abs(s[i] - *p) < 10);
break;
}
printf("%d\n", ans);
}
return 0;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,19 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
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;
}

@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:\\PortableApps\\MSYS2\\mingw64\\bin\\gcc.exe",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}

@ -0,0 +1,5 @@
{
"files.associations": {
"vector": "cpp"
}
}

@ -0,0 +1,23 @@
/*
* @lc app=leetcode id=1 lang=cpp
*
* [1] Two Sum
*/
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
vector<int> twoSum(vector<int> &nums, int target)
{
unordered_map<int, int> m;
for (int i = 0; i < nums.size(); i++)
{
auto ite = m.find(target - nums[i]);
if (ite != m.end())
return {ite->second, i};
m[nums[i]] = i;
}
return {0, 0};
}
};

@ -0,0 +1,133 @@
/*
* @lc app=leetcode id=13 lang=cpp
*
* [13] Roman to Integer
*
* https://leetcode.com/problems/roman-to-integer/description/
*
* algorithms
* Easy (53.27%)
* Likes: 1444
* Dislikes: 2872
* Total Accepted: 488.4K
* Total Submissions: 916.4K
* Testcase Example: '"III"'
*
* Roman numerals are represented by seven different symbols: I, V, X, L, C, D
* and M.
*
*
* Symbol Value
* I 1
* V 5
* X 10
* L 50
* C 100
* D 500
* M 1000
*
* For example, two is written as II in Roman numeral, just two one's added
* together. Twelve is written as, XII, which is simply X + II. The number
* twenty seven is written as XXVII, which is XX + V + II.
*
* Roman numerals are usually written largest to smallest from left to right.
* However, the numeral for four is not IIII. Instead, the number four is
* written as IV. Because the one is before the five we subtract it making
* four. The same principle applies to the number nine, which is written as IX.
* There are six instances where subtraction is used:
*
*
* I can be placed before V (5) and X (10) to make 4 and 9. 
* X can be placed before L (50) and C (100) to make 40 and 90. 
* C can be placed before D (500) and M (1000) to make 400 and 900.
*
*
* Given a roman numeral, convert it to an integer. Input is guaranteed to be
* within the range from 1 to 3999.
*
* Example 1:
*
*
* Input: "III"
* Output: 3
*
* Example 2:
*
*
* Input: "IV"
* Output: 4
*
* Example 3:
*
*
* Input: "IX"
* Output: 9
*
* Example 4:
*
*
* Input: "LVIII"
* Output: 58
* Explanation: L = 50, V= 5, III = 3.
*
*
* Example 5:
*
*
* Input: "MCMXCIV"
* Output: 1994
* Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
*
*/
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
int romanToInt(const string &s)
{
auto str = s.c_str();
int res = 0, len = s.size();
for (int i = 0; i < len; i++)
switch (str[i])
{
case 'I':
if (str[i + 1] == 'V')
res += 4, i++;
else if (str[i + 1] == 'X')
res += 9, i++;
else
res += 1;
break;
case 'X':
if (str[i + 1] == 'L')
res += 40, i++;
else if (str[i + 1] == 'C')
res += 90, i++;
else
res += 10;
break;
case 'C':
if (str[i + 1] == 'D')
res += 400, i++;
else if (str[i + 1] == 'M')
res += 900, i++;
else
res += 100;
break;
case 'V':
res += 5;
break;
case 'L':
res += 50;
break;
case 'D':
res += 500;
break;
case 'M':
res += 1000;
break;
}
return res;
}
};

@ -0,0 +1,57 @@
/*
* @lc app=leetcode id=7 lang=cpp
*
* [7] Reverse Integer
*
* https://leetcode.com/problems/reverse-integer/description/
*
* algorithms
* Easy (25.49%)
* Likes: 2437
* Dislikes: 3788
* Total Accepted: 801.8K
* Total Submissions: 3.1M
* Testcase Example: '123'
*
* Given a 32-bit signed integer, reverse digits of an integer.
*
* Example 1:
*
*
* Input: 123
* Output: 321
*
*
* Example 2:
*
*
* Input: -123
* Output: -321
*
*
* Example 3:
*
*
* Input: 120
* Output: 21
*
*
* Note:
* Assume we are dealing with an environment which could only store integers
* within the 32-bit signed integer range: [2^31,  2^31  1]. For the purpose
* of this problem, assume that your function returns 0 when the reversed
* integer overflows.
*
*/
class Solution
{
public:
int reverse(int x)
{
long long y = 0;
for (; x; x /= 10)
y = y * 10 + x % 10;
if (y < -2147483648ll || y > 2147483647ll) y = 0;
return y;
}
};

@ -0,0 +1,61 @@
/*
* @lc app=leetcode id=9 lang=cpp
*
* [9] Palindrome Number
*
* https://leetcode.com/problems/palindrome-number/description/
*
* algorithms
* Easy (44.86%)
* Likes: 1620
* Dislikes: 1373
* Total Accepted: 674.1K
* Total Submissions: 1.5M
* Testcase Example: '121'
*
* Determine whether an integer is a palindrome. An integer is a palindrome
* when it reads the same backward as forward.
*
* Example 1:
*
*
* Input: 121
* Output: true
*
*
* Example 2:
*
*
* Input: -121
* Output: false
* Explanation: From left to right, it reads -121. From right to left, it
* becomes 121-. Therefore it is not a palindrome.
*
*
* Example 3:
*
*
* Input: 10
* Output: false
* Explanation: Reads 01 from right to left. Therefore it is not a
* palindrome.
*
*
* Follow up:
*
* Coud you solve it without converting the integer to a string?
*
*/
class Solution
{
public:
bool isPalindrome(int x)
{
char buf[20];
sprintf(buf, "%d", x);
for (int i = 0, j = strlen(buf); i < j;)
if (buf[i++] != buf[--j])
return false;
return true;
}
};

@ -69,3 +69,4 @@ int main()
}
return 0;
}
//ljtql
Loading…
Cancel
Save