Sat, 31 Oct 2020 12:12:56 +0800

master
大蒟蒻 5 years ago
commit 82fd5ccc79

@ -39,5 +39,6 @@
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp"
}
},
"python.formatting.provider": "yapf"
}

@ -1 +0,0 @@
Noisy Shadow 59

@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options("/Zc:__cplusplus")
endif()
include_directories("C:\\Programs\\GCC\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32")
add_executable(P01 P01.cpp)
add_executable(P02 P02.cpp)
add_executable(P03 P03.cpp)
add_executable(P04 P04.cpp)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options("/Zc:__cplusplus")
endif()
include_directories("C:\\Programs\\GCC\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\c++\\x86_64-w64-mingw32")
add_executable(P01 P01.cpp)
add_executable(P02 P02.cpp)
add_executable(P03 P03.cpp)
add_executable(P04 P04.cpp)
add_executable(P05 P05.cpp)

@ -1,21 +1,21 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int l[N], r[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d%d", l + i, r + i);
int L = *min_element(l + 1, l + n + 1);
int R = *max_element(r + 1, r + n + 1);
int ans = -1;
for (int i = 1; i <= n; i++)
if (l[i] == L && r[i] == R)
ans = i;
printf("%d", ans);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
int l[N], r[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d%d", l + i, r + i);
int L = *min_element(l + 1, l + n + 1);
int R = *max_element(r + 1, r + n + 1);
int ans = -1;
for (int i = 1; i <= n; i++)
if (l[i] == L && r[i] == R)
ans = i;
printf("%d", ans);
return 0;
}

@ -1,22 +1,22 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int a1[N], a2[N], b[N], d[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i < n; i++)
scanf("%d", a1 + i), a1[i] += a1[i - 1];
for (int i = 1; i < n; i++)
scanf("%d", a2 + i), a2[i] += a2[i - 1];
for (int i = 0; i < n; i++)
scanf("%d", b + i);
for (int i = 0; i < n; i++)
d[i] = a1[i] + b[i] + (a2[n - 1] - a2[i]);
sort(d, d + n);
printf("%d", d[0] + d[1]);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int a1[N], a2[N], b[N], d[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i < n; i++)
scanf("%d", a1 + i), a1[i] += a1[i - 1];
for (int i = 1; i < n; i++)
scanf("%d", a2 + i), a2[i] += a2[i - 1];
for (int i = 0; i < n; i++)
scanf("%d", b + i);
for (int i = 0; i < n; i++)
d[i] = a1[i] + b[i] + (a2[n - 1] - a2[i]);
sort(d, d + n);
printf("%d", d[0] + d[1]);
return 0;
}

@ -1,30 +1,30 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
char buf[N];
int diff[N];
int calc(char a, char b)
{
if (a > b) swap(a, b);
return min(b - a, a + 26 - b);
}
int main()
{
int n, p;
scanf("%d%d%s", &n, &p, buf);
p--;
if (p >= (n >> 1)) p = n - p - 1, reverse(buf, buf + n);
for (int i = 0; i < (n >> 1); i++) diff[i] = calc(buf[i], buf[n - i - 1]);
int L = p, R = p;
for (int i = p; i >= 0; i--)
if (diff[i]) L = i;
for (int i = p; i < (n >> 1); i++)
if (diff[i]) R = i;
int base_ans = accumulate(diff + L, diff + R + 1, 0);
if (L == p) return printf("%d", base_ans + R - p), 0;
if (R == p) return printf("%d", base_ans + p - L), 0;
printf("%d", base_ans + R - L + min(R - p, p - L));
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
char buf[N];
int diff[N];
int calc(char a, char b)
{
if (a > b) swap(a, b);
return min(b - a, a + 26 - b);
}
int main()
{
int n, p;
scanf("%d%d%s", &n, &p, buf);
p--;
if (p >= (n >> 1)) p = n - p - 1, reverse(buf, buf + n);
for (int i = 0; i < (n >> 1); i++) diff[i] = calc(buf[i], buf[n - i - 1]);
int L = p, R = p;
for (int i = p; i >= 0; i--)
if (diff[i]) L = i;
for (int i = p; i < (n >> 1); i++)
if (diff[i]) R = i;
int base_ans = accumulate(diff + L, diff + R + 1, 0);
if (L == p) return printf("%d", base_ans + R - p), 0;
if (R == p) return printf("%d", base_ans + p - L), 0;
printf("%d", base_ans + R - L + min(R - p, p - L));
return 0;
}

@ -1,21 +1,21 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
char buf[N];
int main()
{
scanf("%s", buf);
int len = strlen(buf);
bool flag = false;
putchar(buf[0]);
for (int i = 1; i < len;)
if (memcmp(buf + i, "dot", 3) == 0 && i + 3 < len)
putchar('.'), i += 3;
else if (!flag && memcmp(buf + i, "at", 2) == 0 && i + 2 < len)
putchar('@'), i += 2, flag = true;
else
putchar(buf[i]), i++;
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 20;
char buf[N];
int main()
{
scanf("%s", buf);
int len = strlen(buf);
bool flag = false;
putchar(buf[0]);
for (int i = 1; i < len;)
if (memcmp(buf + i, "dot", 3) == 0 && i + 3 < len)
putchar('.'), i += 3;
else if (!flag && memcmp(buf + i, "at", 2) == 0 && i + 2 < len)
putchar('@'), i += 2, flag = true;
else
putchar(buf[i]), i++;
return 0;
}

@ -1,29 +1,29 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 10;
int w[N], b[N];
int p[N];
bool u[N];
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%d", w + i);
for (int i = 1; i <= m; i++)
scanf("%d", b + i);
memset(p, 0, sizeof(p));
long long ans = 0;
for (int i = 1; i <= m; i++)
{
memset(u, 0, sizeof(u));
for (int j = p[b[i]] + 1; j < i; j++)
if (!u[b[j]])
ans += w[b[j]], u[b[j]] = true;
p[b[i]] = i;
}
printf("%lld", ans);
return 0;
}
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 10;
int w[N], b[N];
int p[N];
bool u[N];
int main()
{
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%d", w + i);
for (int i = 1; i <= m; i++)
scanf("%d", b + i);
memset(p, 0, sizeof(p));
long long ans = 0;
for (int i = 1; i <= m; i++)
{
memset(u, 0, sizeof(u));
for (int j = p[b[i]] + 1; j < i; j++)
if (!u[b[j]])
ans += w[b[j]], u[b[j]] = true;
p[b[i]] = i;
}
printf("%lld", ans);
return 0;
}

@ -1,15 +0,0 @@
```cpp
invT[1] = 1;
for (int i = 2; i < N; i++)
invT[i] = (mod - mod / i) * invT[mod % i] % mod;
```
$$
p=ax+b \\
ax+b \equiv 0 \pmod p\\
ab^{-1}+x^{-1} \equiv 0 \pmod p \\
x^{-1} \equiv -ab^{-1} \pmod p \\
x^{-1} \equiv -\left \lfloor \frac{p}{x} \right \rfloor (p\bmod x)^{-1} \pmod p \\
x^{-1} \equiv (p-p/x) (p\bmod x)^{-1} \pmod p \\
$$

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,90 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
int T, n, k, x;
read(T);
while (T--)
{
read(n, k);
priority_queue<int, vector<int>, greater<int>> Q;
for (int i = 0; i < n; i++) read(x), Q.push(x);
int cnt = 0;
while (Q.size() > 1)
{
int m1 = Q.top();
Q.pop();
int m2 = Q.top();
Q.pop();
if (m1 + m2 > k) break;
Q.push(m1 + m2);
Q.push(m1);
cnt++;
}
printf("%d\n", cnt);
}
return 0;
}

@ -0,0 +1,87 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 1e5 + 50;
int a[N];
int main()
{
int T, n, k;
read(T);
while (T--)
{
read(n, k);
for (int i = 0; i < n; i++) read(a[i]);
int ans = 0;
int f = 0;
for (int i = 0; i < n; i++)
{
if (a[i] * 2 < k) printf("1 ");
if (a[i] * 2 > k) printf("0 ");
if (a[i] * 2 == k) printf("%d ", f ^= 1);
}
puts("");
}
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,11 @@
project(cf1417)
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++\\10.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)

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,16 @@
project(cf1425)
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++\\10.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)

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,93 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 1e3 + 50;
int ans[N];
int fans[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i < n; i++)
{
printf("? %d %d\n", i, n);
fflush(stdout);
scanf("%d", ans + i);
}
for (int i = 0; i < n - 2; i++)
fans[i] = ans[i + 1] - ans[i + 2];
printf("? %d %d\n", 1, n - 1);
fflush(stdout);
int x;
scanf("%d", &x);
int sum1 = accumulate(fans, fans + n - 2, 0);
fans[n - 2] = x - sum1;
fans[n - 1] = ans[1] - sum1 - fans[n - 2];
printf("!");
for (int i = 0; i < n; i++) printf(" %d", fans[i]);
puts("");
fflush(stdout);
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
return 0;
}

@ -0,0 +1,81 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
char *ans[] = {"Tidak", "Ya"};
int main()
{
int T, a, b, c, d;
read(T);
while (T--)
{
read(a, b, c, d);
c += b, d += a;
if ((a + b) & 1) //neg
printf("%s %s Tidak Tidak\n", ans[!!d], ans[!!c]);
else //pos
printf("Tidak Tidak %s %s\n", ans[!!c], ans[!!d]);
}
return 0;
}

@ -0,0 +1,70 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 105;
int a[N], b[N], c[N];
int main()
{
int T, n;
read(T);
while (T--)
{
read(n);
for (int i = 0; i < n; i++) read(a[i]);
for (int i = 0; i < n; i++) read(b[i]);
for (int i = 0; i < n; i++) read(c[i]);
int last = -1;
for (int i = 0; i < n - 1; i++)
{
if (a[i] == last)
printf("%d ", last = b[i]);
else
printf("%d ", last = a[i]);
}
if (a[n - 1] != last && a[n - 1] != a[0])
printf("%d\n", a[n - 1]);
else if (b[n - 1] != last && b[n - 1] != a[0])
printf("%d\n", b[n - 1]);
else
printf("%d\n", c[n - 1]);
}
return 0;
}

@ -0,0 +1,85 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int a[105];
int main()
{
int T, n, k;
read(T);
while (T--)
{
read(n, k);
for (int i = 0; i < n; i++) read(a[i]);
sort(a, a + n);
int l = unique(a, a + n) - a;
if (l != 1 && k == 1)
puts("-1");
else if (l == 1)
puts("1");
else
printf("%d\n", (l - 1 + k - 2) / (k - 1));
}
return 0;
}

@ -0,0 +1,112 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 1e5 + 50;
double ta[N], tb[N];
int p[N];
int main()
{
int T, n, len;
read(T);
while (T--)
{
read(n, len);
for (int i = 1; i <= n; i++) read(p[i]);
p[n + 1] = len;
tb[n + 1] = 0;
for (int i = 1, curspeed = 1; i <= n + 1; i++)
{
ta[i] = ta[i - 1] + 1.0 * (p[i] - p[i - 1]) / curspeed;
curspeed++;
}
for (int i = n, curspeed = 1; i >= 0; i--)
{
tb[i] = tb[i + 1] + 1.0 * (p[i + 1] - p[i]) / curspeed;
curspeed++;
}
for (int i = 0; i <= n + 1; i++)
if (ta[i] > tb[i])
{
i--;
double ans = 0;
double dis = p[i + 1] - p[i];
if (ta[i] > tb[i + 1])
{
ans += ta[i];
dis -= abs(ta[i] - tb[i + 1]) * (n - i + 1);
ans += dis / (n + 2);
}
else
{
ans += tb[i + 1];
dis -= abs(ta[i] - tb[i + 1]) * (i + 1);
ans += dis / (n + 2);
}
printf("%.15lf\n", ans);
break;
}
}
return 0;
}

@ -0,0 +1,128 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
namespace Min25
{
const int N = 1000010;
int prime[N], id1[N], id2[N], flag[N], ncnt, m;
ll g[N], sum[N], a[N], T, n;
inline int ID(ll x) { return x <= T ? id1[x] : id2[n / x]; }
inline ll calc(ll x) { return x * (x + 1) / 2 - 1; }
inline ll f(ll x) { return x; }
void initPrime()
{
T = 1e5 + 50;
for (int i = 2; i <= T; i++)
{
if (!flag[i]) prime[++ncnt] = i, sum[ncnt] = sum[ncnt - 1] + i;
for (int j = 1; j <= ncnt && i * prime[j] <= T; j++)
{
flag[i * prime[j]] = 1;
if (i % prime[j] == 0) break;
}
}
}
void init()
{
m = 0;
T = sqrt(n + 0.5);
for (ll l = 1; l <= n; l = n / (n / l) + 1)
{
a[++m] = n / l;
if (a[m] <= T)
id1[a[m]] = m;
else
id2[n / a[m]] = m;
g[m] = calc(a[m]);
}
for (int i = 1; i <= ncnt; i++)
for (int j = 1; j <= m && (ll)prime[i] * prime[i] <= a[j]; j++) g[j] = g[j] - (ll)prime[i] * (g[ID(a[j] / prime[i])] - sum[i - 1]);
}
inline ll solve(ll x)
{
if (x <= 1) return x;
return n = x, init(), g[ID(n)];
}
} // namespace Min25
ll calc1(ll _n, ll mod)
{
__int128 x = _n;
return ((2 + x + 1) * x / 2 - 4) % mod;
}
int main()
{
Min25::initPrime();
int T;
ll __N, mod;
read(T);
while (T--)
{
read(__N, mod);
ll ans = calc1(__N, mod);
ans = ans + Min25::solve(__N + 1) % mod;
printf("%lld\n", ans % mod);
}
return 0;
}

@ -1,20 +0,0 @@
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;
class Main {
public static void main(String[] argv) {
String sp = System.getProperty("line.separator");
PrintStream cout = System.out;
try (Scanner cin = new Scanner(System.in)) {
int T = cin.nextInt();
for (int t = 1; t <= T; t++) {
BigInteger ba = cin.nextBigInteger(), bb = cin.nextBigInteger();
cout.printf("Case %d:%s%s + %s = %s%s", t, sp, ba, bb, ba.add(bb), sp);
if (t != T)
cout.println();
}
}
}
}

@ -0,0 +1,103 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
struct node
{
int type;
union
{
char s[10];
int v;
};
};
int cmp(const list<node> &s1, const list<node> &s2)
{
}
list<node> build(char *buf)
{
list<node> r;
for (char *p = buf; *p; p++)
{
}
return r;
}
int main()
{
int n;
read(n);
char buf[16];
scanf("%s", buf);
auto s0 = build(buf);
for (int i = 0; i < n; i++)
{
scanf("%s", buf);
if (cmp(build(buf), s0))
puts("+");
else
puts("-");
}
return 0;
}

@ -0,0 +1,32 @@
import re
def proc(l):
r = []
for v in l:
if v.isdigit():
r.append(int(v))
else:
for ch in v:
r.append(10**10 + ord(ch))
r.append(-1)
return r
def cmp(a, b):
for i, j in zip(a, b):
if i < j:
return True
if i > j:
return False
spl = re.compile(r'(\d+|[a-zA-Z]+)')
n = int(input())
s0 = proc(spl.findall(input()))
for i in range(n):
s = proc(spl.findall(input()))
if cmp(s, s0):
print('-')
else:
print('+')

@ -0,0 +1,88 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 1e5 + 50;
pair<int, int> a[N];
int b[N << 1];
int presum[N << 1];
int main()
{
int n;
read(n);
for (int i = 0; i < n; i++)
read(a[i].first, a[i].second), b[i << 1] = a[i].first, b[i << 1 | 1] = a[i].second;
sort(b, b + n + n);
auto be = unique(b, b + n + n);
for (int i = 0; i < n; i++)
a[i].first = lower_bound(b, be, a[i].first) - b + 1,
a[i].second = lower_bound(b, be, a[i].second) - b + 1;
for (int i = 0; i < n; i++)
presum[a[i].first]++, presum[a[i].second]--;
for (int i = 1; i <= be - b; i++)
presum[i] += presum[i - 1];
auto maxp = max_element(presum, presum + (be - b) + 1);
printf("%d %d", b[maxp - presum - 1], *maxp);
return 0;
}

@ -0,0 +1,8 @@
project(nowcoder7831)
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++\\10.2.0\\x86_64-w64-mingw32")
add_executable(B B.cpp)

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ItemDefinitionGroup>
<ClCompile>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<RuntimeLibrary Condition="'$(Configuration)'=='Release'">MultiThreaded</RuntimeLibrary>
<RuntimeLibrary Condition="'$(Configuration)'=='Debug'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
<PropertyGroup>
<IncludePath>D:\PortableApps\MSYS2\mingw64\include\c++\10.2.0\x86_64-w64-mingw32;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Label="Globals">
<VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
<VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
<ProjectGuid>{AFFB95BF-30B4-4DFB-B1F1-98F24D67BD64}</ProjectGuid>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<ClCompile Include="B.cpp" />
</ItemGroup>
</Project>

@ -1,11 +0,0 @@
from socket import *
from struct import *
while True:
st = input(">>> ")
s = socket(AF_INET, SOCK_STREAM)
s.connect(("127.0.0.1", 8888))
s.sendall(pack("!i", len(st.encode())))
s.sendall(st.encode())
print(s.recv(len(st)).decode())
s.close()

@ -1,18 +0,0 @@
from socket import *
from struct import *
from threading import *
s = socket(AF_INET, SOCK_STREAM)
s.bind(('', 8888))
s.listen(100)
def proc(cs):
msglen = unpack("!i", cs.recv(4))[0]
msg = cs.recv(msglen)
cs.sendall(msg.decode().upper().encode())
while True:
(cs, addr) = s.accept()
# Thread(None, proc, args=(cs, )).start()
proc(cs)

Binary file not shown.

@ -1,19 +0,0 @@
template <size_t N, size_t M = N>
struct Graph
{
// Basic
struct Edge
{
int nxt, to, len;
};
int adj[N], ecnt;
Edge E[M];
void addEdge(int f, int t, int l)
{
E[++ecnt] = {adj[f], t, l};
adj[f] = ecnt;
}
// Dijkstra
// ISAP
};

@ -0,0 +1,101 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 1e5 + 50;
int a[N];
int main()
{
int T, n, m;
read(T);
while (T--)
{
read(n, m);
for (int i = 0; i < n; i++) read(a[i]);
int p = *a;
sort(a, a + n);
int pos = lower_bound(a, a + n, p) - a;
int pos2 = upper_bound(a, a + n, p) - a;
a[pos]++, m--;
for (int i = n - 1; i >= pos2; i--)
{
if (m == 0) break;
a[i]++, m--;
}
for (int i = 0; i < pos; i++)
{
if (m == 0) break;
a[i]++, m--;
}
for (int i = pos + 1; i < pos2; i++)
{
if (m == 0) break;
a[i]++, m--;
}
sort(a, a + n);
int pos3 = lower_bound(a, a + n, p + 1) - a;
printf("%d\n", n - pos3);
}
return 0;
}

@ -0,0 +1,77 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
int main()
{
ll mod = 1e9 + 7;
ll n, a, b;
read(n);
while (n--)
{
read(a, b);
printf("%lld\n", b * fpow(2, a - 1, mod) % mod);
}
return 0;
}

@ -0,0 +1,77 @@
#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 OPX(op, t, x) operator op(CRP(t, x))
#define OPL(t, x) bool OPX(<, t, x) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef int64_t ll, i64;
typedef uint64_t ull, u64;
template <typename... Types>
using comtype = typename common_type<Types...>::type;
template <typename T>
using enable_if_arithmetic = typename enable_if<is_arithmetic<T>::value>::type;
template <typename T>
using enable_if_integral = typename enable_if<is_integral<T>::value>::type;
inline char getchar(int)
{
static char buf[64 << 20], *S = buf, *T = buf;
if (S == T) T = fread(S = buf, 1, 64 << 20, stdin) + buf;
return S == T ? EOF : *S++;
}
template <typename T, typename = enable_if_integral<T>>
inline bool read(T &x)
{
int ch = x = 0, f = 1;
while (!isdigit(ch = getchar()))
if (ch == EOF)
return false;
else if (ch == '-')
f = 0;
for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
return x = f ? x : -x, true;
}
template <typename T, typename... Args, typename = enable_if_integral<T>>
inline bool read(T &x, Args &... args) { return read(x) && read(args...); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmin(CRP(T1, v1), CRP(T2, v2)) { return min<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmin(CRP(T, v), const Args &... args) { return min<TResult>(v, mmin(args...)); }
template <typename T1, typename T2, typename TResult = comtype<T1, T2>>
inline TResult mmax(CRP(T1, v1), CRP(T2, v2)) { return max<TResult>(v1, v2); }
template <typename T, typename... Args, typename TResult = comtype<T, Args...>>
inline TResult mmax(CRP(T, v), const Args &... args) { return max<TResult>(v, mmax(args...)); }
inline ll gcd(ll a, ll b)
{
for (; b; swap(a, b)) a %= b;
return a;
}
inline ll fpow(ll a, ll b, ll m)
{
ll r = 1;
for (; b; b >>= 1, a = a * a % m)
if (b & 1) r = r * a % m;
return r;
}
constexpr double eps = 1e-8;
inline int sgn(double x) { return x > eps ? 1 : x < -eps ? -1 : 0; }
const int N = 1050;
int a[N][N];
int main()
{
int n;
read(n);
INF(a);
for (int i = 1; i < n; i++)
for (int j = 1; j < n; j++)
read(a[i][j]);
return 0;
}

@ -0,0 +1,27 @@
import string
from collections import defaultdict
a = input()
b = input()
n = int(input())
mps = []
mp1 = defaultdict(int)
mp2 = defaultdict(int)
for ch in string.ascii_letters:
mp1[ch] = a.count(ch)
mp2[ch] = b.count(ch)
mps.append(mp1)
mps.append(mp2)
for i in range(2, n):
nmp = {}
for ch in string.ascii_letters:
nmp[ch] = mps[-1][ch] + mps[-2][ch]
mps.append(nmp)
if n == 1:
amp = mp1
elif n == 2:
amp = mp2
else:
amp = mps[-1]
for ch in string.ascii_uppercase + string.ascii_lowercase:
if amp[ch] > 0:
print(ch + ": " + str(amp[ch]))
Loading…
Cancel
Save