Wed, 17 Jul 2019 22:24:17 +0800

master
大蒟蒻 6 years ago
parent c4ceda5a02
commit 70c4390e34

@ -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++\\8.3.0\\x86_64-w64-mingw32")
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)
add_executable(P6 P6.cpp)
add_executable(P7 P7.cpp)
add_executable(P8 P8.cpp)

@ -0,0 +1,11 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n;
scanf("%lld", &n);
printf("%lld", n * n);
return 0;
}

@ -0,0 +1,56 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int a[15], T, n, ans;
int c[15];
set<int> S;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void dfs(int st)
{
ans = max(ans, st);
for (int i = 0; i < n; i++)
if (!S.count(a[i]))
{
bool flag = true;
for (int j = 0; j < st; j++)
if (gcd(a[i], c[j]) != 1)
flag = false;
if (flag)
{
S.insert(a[i]);
c[st] = a[i];
dfs(st + 1);
S.erase(a[i]);
}
}
}
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
ans = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
//dfs(0);
for (int i = 0; i < (1 << n); i++)
{
bool flag = true;
for (int j = 0; j < n; j++)
for (int k = j + 1; k < n; k++)
if ((i & (1 << j)) && (i & (1 << k)))
if (gcd(a[j], a[k]) != 1)
flag = false;
if (flag)
{
int cnt = 0;
for (int x = i; x; x -= x & -x) cnt++;
ans = max(ans, cnt);
}
}
cout << ans << endl;
}
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;
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
string s, t;
cin >> s >> t;
int sl = s.length();
int tl = t.length();
if (sl - 2 != tl)
{
puts("0");
continue;
}
int cur = 0, cut = 0;
bool ok = 1;
for (int i = 0; i < sl; i++)
{
if (s[i] == t[cur])
{
cur++;
continue;
}
else
{
cut++;
}
if (cut > 2) ok = 0;
}
if (ok && cut == 2)
puts("1");
else
puts("0");
}
return 0;
}

@ -0,0 +1,22 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
map<int, int> M;
for (int i = 0; i < 18; i++)
{
int x;
scanf("%d", &x);
M[x]++;
}
for (auto &i : M)
if (i.first)
i.second %= 2;
int ans = 0;
for (auto &i : M)
ans += i.second;
cout << ans;
return 0;
}

@ -0,0 +1,161 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
#define R 3
#define U 0
#define D 1
#define L 2
using namespace std;
int nxt[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
char mp[20][20];
int n;
bool tex(int x, int y)
{
if (x <= n && x >= 1 && y >= 1 && y <= n)
{
if (mp[x][y] != '#')
return true;
else
return false;
}
return false;
}
void tx(int x, int y) {
if (tex(x-1,y)&&mp[x-1][y]=='T')
}
int main()
{
scanf("%d", &n);
int sx, sy, tx, ty;
for (int i = 1; i <= n; i++)
{
scanf("%s", mp[i]);
for (int j = n; j > 0; j--)
{
mp[i][j] = mp[i][j - 1];
if (mp[i][j] == 'S')
{
sx = i;
sy = j;
}
if (mp[i][j] == 'T')
{
tx = i;
ty = j;
}
}
}
int nx = sx, ny = sy, tohe = R;
int wx = sx, wy = sy + 1;
while (mp[nx][ny] != 'T')
{
if (tohe == R)
{
if (tex(nx + 1, ny + 1) && tex(nx , ny+1) )
{
printf("D");
tohe = D;
nx = nx + 1;
ny = ny + 1;
}
else if (tex(nx, ny+1))
{
printf("D");
nx = nx + 1;
}
else if (tex(nx-1, ny))
{
printf("D");
tohe = U;
}
else
{
printf("D");
tohe = L;
}
}
else if (tohe == U)
{
if (tex(nx - 1, ny + 1) && tex(nx - 1, ny) )
{
printf("R");
tohe = D;
nx = nx - 1;
ny = ny + 1;
}
else if (tex(nx - 1, ny))
{
printf("R");
nx = nx - 1;
}
else if (tex(nx, ny - 1))
{
printf("R");
tohe = L;
}
else
{
printf("R");
tohe = D;
}
}
else if (tohe == L)
{
if (tex(nx - 1, ny - 1) && tex(nx, ny-1) )
{
printf("U");
tohe = U;
nx = nx - 1;
ny = ny - 1;
}
else if (tex(nx, ny-1))
{
printf("U");
ny = ny - 1;
}
else if (tex(nx+1, ny))
{
printf("U");
tohe = D;
}
else
{
printf("U");
tohe = R;
}
}
else if (tohe == D)
{
if (tex(nx + 1, ny - 1) && tex(nx + 1, ny) )
{
printf("L");
tohe = L;
nx = nx + 1;
ny = ny - 1;
}
else if (tex(nx + 1, ny))
{
printf("L");
nx = nx + 1;
}
else if (tex(nx, ny + 1))
{
printf("L");
tohe = R;
}
else
{
printf("L");
tohe = U;
}
}
}
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;
const int N = 1e6 + 50;
pair<int, int> a[N];
int main()
{
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
int cnt = 0;
for (int i = 1; i < n; i++)
for (int j = 1; j < m; j++)
a[cnt++] = {i, j};
set<pair<int, int>> S{a, a + cnt};
while (q--)
{
int x, y;
scanf("%d%d", &x, &y);
decltype(S)::iterator ite;
ite = S.find(make_pair(x, y));
if (ite != S.end()) S.erase(ite);
ite = S.find(make_pair(x - 1, y));
if (ite != S.end()) S.erase(ite);
ite = S.find(make_pair(x, y - 1));
if (ite != S.end()) S.erase(ite);
ite = S.find(make_pair(x - 1, y - 1));
if (ite != S.end()) S.erase(ite);
printf("%lld\n", S.size());
}
return 0;
}

@ -0,0 +1,9 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,56 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
int a[N];
int main()
{
/* int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", a + i);
a[0] = a[n + 1] = 0x3f3f3f3f;
int cnt = 0;
for (int i = 1; i <= n; i++)
if (a[i - 1] <= a[i] && a[i] >= a[i + 1])
cnt++;
cout << cnt;
return 0;*/
int n;
scanf("%d", &n);
int d = 0, last = 2147483640, os = 1;
for (int i = 1; i <= n; i++)
{
int s;
scanf("%d", &s);
if (os == 1)
{
if (last > s)
{
last = s;
}
else
{
os = 2;
last = s;
d++;
continue;
}
}
else if (os == 2)
{
if (last < s)
{
last = s;
}
else
{
os = 1;
last = s;
}
}
}
printf("%d\n", d);
return 0;
}

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options("/Zc:__cplusplus /wd6031")
endif()
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32")
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)

@ -0,0 +1,47 @@
#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 a1[N], a2[N], b1[N], b2[N], a[N], b[N];
int main()
{
int T, n, m;
scanf("%d", &T);
while (T--)
{
int ca1 = 0, ca2 = 0, cb1 = 0, cb2 = 0;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", a + i);
for (int i = 0; i < m; i++) scanf("%d", b + i);
for (int i = 0, x; i < n; i++)
{
scanf("%d", &x);
if (x)
a1[ca1++] = a[i];
else
a2[ca2++] = a[i];
}
for (int i = 0, x; i < m; i++)
{
scanf("%d", &x);
if (x)
b1[cb1++] = b[i];
else
b2[cb2++] = b[i];
}
sort(a1, a1 + ca1);
sort(a2, a2 + ca2);
sort(b1, b1 + cb1);
sort(b2, b2 + cb2);
int ans = 0;
for (int i = 0, j = 0; i < ca1 && j < cb2; j++)
if (a1[i] < b2[j])
ans++, i++;
for (int i = 0, j = 0; i < cb1 && j < ca2; j++)
if (b1[i] < a2[j])
ans++, i++;
printf("%d\n", ans);
}
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,54 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[256];
char mp[2005][2005];
inline int t(int i, int j) { return mp[i][j] - '0'; }
inline int nxt(int i, int j) { return (((t(i, j) * 3 + t(i - 1, j)) * 3 + t(i + 1, j)) * 3 + t(i, j - 1)) * 3 + t(i, j + 1); }
int vis[2005][2005];
int main()
{
int T, n, m, a, b;
ll k;
scanf("%d", &T);
while (T--)
{
scanf("%d%d%d%d%lld%s", &n, &m, &a, &b, &k, s);
a--, b--;
int ans = 0;
for (int i = 0; i < n; i++) scanf("%s", mp + i);
k = min(k, 2000ll * n * m);
while (k--)
{
//printf("** %d %d\n", a, b);
char op = s[nxt(a, b)];
switch (op)
{
case 'U':
if (t(a - 1, b) != 1) a--;
break;
case 'D':
if (t(a + 1, b) != 1) a++;
break;
case 'L':
if (t(a, b - 1) != 1) b--;
break;
case 'R':
if (t(a, b + 1) != 1) b++;
break;
case 'P':
if (mp[a][b] == '2') ans++;
mp[a][b] = '0';
break;
case 'I':
break;
default:
break;
}
}
printf("%d\n", ans);
}
return 0;
}

@ -0,0 +1,9 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
puts("UDRUDRLLRLLRUDRLLRDDRDDRLLRRDRRDRLLRLDRUDRLLRDDRDDRLLRUURUURLLRUURUURLLRDDRDDRLLRIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP");
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;
const int N = 105;
long long a[N], b[N];
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for (int i = n - 1; i >= 0; i--) scanf("%lld", a + i);
for (int i = n - 1; i >= 0; i--) scanf("%lld", b + i);
for (int i = 1; i < n; i++) a[i] += a[i - 1], b[i] += b[i - 1];
bool flag = true;
for (int i = 0; i < n; i++)
if (a[i] > b[i])
flag = false;
puts(flag ? "Yes" : "No");
}
return 0;
}

@ -0,0 +1,15 @@
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++\\8.3.0\\x86_64-w64-mingw32")
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)
add_executable(P6 P6.cpp)
add_executable(P7 P7.cpp)
add_executable(P8 P8.cpp)
add_executable(P9 P9.cpp)

@ -0,0 +1,9 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
add_compile_options("/Zc:__cplusplus" "/wd6031")
endif()
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\8.3.0\\x86_64-w64-mingw32")
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)
add_executable(P6 P6.cpp)

@ -0,0 +1,23 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T, x, y, a, b;
cin >> T;
while (T--)
{
cin >> x >> y >> a >> b;
if ((x == 1 && a >= 1) || (y == 1 && b >= 1) || ((x == 2 && y == 2 && a + b >= 3)))
puts("INF");
else
{
int cnt = 0;
for (int c1 = a, c2 = b, tmp; c1 >= x || c2 >= y; c1 = c1 % x + tmp, c2 = c2 % y + tmp)
cnt += (tmp = c1 / x + c2 / y);
printf("%d\n", cnt);
}
}
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,46 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using cr = const T &;
struct p
{
int l, r, id;
} a[50050];
bool cmp(cr<p> l, cr<p> r)
{
return l.l == r.l ? l.r < r.r : l.l < r.l;
}
bool cmp2(cr<p> l, cr<p> r)
{
return l.r == r.r ? l.l < r.l : l.r > r.r;
}
int ans[50050];
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d%d", &a[i].l, &a[i].r), a[i].id = i + 1;
sort(a, a + n, cmp);
int cnt = 0;
p ps[3] = {a[0], a[1]};
for (int i = 2; i < n; i++)
{
ps[2] = a[i];
sort(ps, ps + 3, cmp);
bool f = ps[1].l <= ps[0].r && ps[2].l <= ps[0].r && ps[2].l <= ps[1].r;
sort(ps, ps + 3, cmp2);
if (f) ans[cnt++] = ps[0].id, swap(ps[0], ps[2]);
}
sort(ans, ans + cnt);
printf("%d\n", cnt);
for (int i = 0; i < cnt; i++) printf("%d ", ans[i]);
putchar('\n');
}
return 0;
}

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.0)
include_directories("D:\\PortableApps\\MSYS2\\mingw64\\include\\c++\\9.1.0\\x86_64-w64-mingw32")
add_executable(Easy1 Easy1.cpp)
add_executable(Easy2 Easy2.cpp)
add_executable(Extra Extra.cpp)
add_executable(Hard1 Hard1.cpp)
add_executable(Hard2 Hard2.cpp)
add_executable(Lunatic1 Lunatic1.cpp)
add_executable(Lunatic2 Lunatic2.cpp)
add_executable(Normal1 Normal1.cpp)
add_executable(Normal2 Normal2.cpp)

@ -0,0 +1,22 @@
#include <bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
int T, n, V, W;
scanf("%d", &T);
while (T--)
{
scanf("%d%d%d", &n, &V, &W);
for (int i = 0; i < n; i++) scanf("%d", a + i);
sort(a, a + n);
int sum = 0, cnt = 0;
while (sum + a[cnt] <= W * (cnt + 1) && cnt < n)
sum += a[cnt++];
if (cnt == 0)
puts("0 0.00");
else
printf("%d %.2lf\n", cnt * V, 0.01 * sum / cnt);
}
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;
const int N = 1e5 + 50;
char s[N];
void die(int x)
{
puts(x ? "YES" : "NO");
exit(0);
}
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
int n;
scanf("%d%s", &n, &s);
puts(find(s, s + n, '8') <= s + n - 11 ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,6 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,33 @@
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
ll a[N];
int main()
{
int T, n, k, ans;
scanf("%d", &T);
for (int t = 1; t <= T; t++)
{
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++) scanf("%lld", a + i);
ll sum = accumulate(a, a + n, 0ll);
if (sum % k)
ans = -1;
else
{
ll tgt = sum / k, cur = 0;
ans = -1;
deque<ll> D(a, a + n);
while (!D.empty())
{
int cur = 0;
while (cur < tgt && !D.empty())
cur += D.front(), D.pop_front(), ans++;
if (cur > tgt) D.push_front(cur - tgt), ans++;
}
}
printf("Case #%d: %d\n", t, ans);
}
return 0;
}

@ -0,0 +1,6 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,6 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,6 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,22 @@
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char s[N];
int main()
{
int n, cnt, ans;
while (~scanf("%d%s", &n, s))
{
cnt = ans = 0;
for (int i = 0; i <= n; i++)
if (s[i] == 'x')
cnt++;
else
{
ans += max(0, cnt - 2);
cnt = 0;
}
printf("%d\n", ans);
}
return 0;
}

@ -0,0 +1,10 @@
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, x, mx = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &x), mx = max(mx, x);
printf("%d", max(0, mx - 25));
return 0;
}

@ -0,0 +1,13 @@
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++\\8.3.0\\x86_64-w64-mingw32")
add_executable(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)
add_executable(P6 P6.cpp)
add_executable(P7 P7.cpp)

@ -0,0 +1,16 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
char s[1050];
int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d%s", &n, s);
puts((s + n - find(s, s + n, '8') > 10) ? "YES" : "NO");
}
return 0;
}

@ -0,0 +1,27 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
puts("? 1 2");
puts("? 2 3");
puts("? 4 5");
puts("? 5 6");
fflush(stdout);
int a[] = {4, 8, 15, 16, 23, 42};
int a12, a23, a45, a56;
scanf("%d%d%d%d", &a12, &a23, &a45, &a56);
do
if (a[0] * a[1] == a12 &&
a[1] * a[2] == a23 &&
a[3] * a[4] == a45 &&
a[4] * a[5] == a56)
{
printf("! %d %d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4], a[5]);
fflush(stdout);
break;
}
while (next_permutation(a, a + 6));
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;
const int N = 5e5 + 50;
int fa[N], sz[N];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void link(int x, int y)
{
int fx = find(x), fy = find(y);
if (fx != fy)
{
fa[fy] = fx;
sz[fx] += sz[fy];
}
}
int main()
{
for (int i = 0; i < N; i++) fa[i] = i, sz[i] = 1;
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0, c, s; i < m; i++)
{
scanf("%d", &c);
if (c == 0) continue;
scanf("%d", &s);
for (int i = 1, x; i < c; i++)
scanf("%d", &x), link(s, x);
}
for (int i = 1; i <= n; i++)
printf("%d ", sz[find(i)]);
return 0;
}

@ -0,0 +1,17 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
char s[N];
int c[N];
int main()
{
int n;
scanf("%d%s", &n, s);
for (int i = 0; i < n; i++) c[i + (s[i] == ')')] += (s[i] == '(') * 2 - 1;
for (int i = 1; i < n; i++) c[i] += c[i - 1];
int th = *max_element(c, c + n) / 2;
for (int i = 0; i < n; i++) putchar('0' + (c[i] > th));
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,12 @@
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(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)
add_executable(P5 P5.cpp)
add_executable(P6 P6.cpp)

@ -0,0 +1,21 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
if (a == b && c == 0)
puts("0");
else
{
if (a + c < b)
puts("-");
else if (b + c < a)
puts("+");
else
puts("?");
}
return 0;
}

@ -0,0 +1,42 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d", &n);
printf("%d\n", n / 2 + 1);
int x = 1, y = 1;
for (int i = 1; i <= n; i++) {
printf("%d %d\n", x, y);
(y == n / 2 + 1 ? x : y)++;
}
return 0;
if (n & 1)
{
printf("%d\n", n / 2 + 1);
for (int i = 1; i <= n / 2 + 1; i++)
printf("%d %d\n", 1, i);
for (int i = n / 2 + 1 + 1; i <= n; i++)
printf("%d %d\n", i - n / 2 - 1, n / 2 + 1);
}
else
{
printf("%d\n", n / 2 + 1);
for (int i = 1; i <= n / 2 + 1; i++)
printf("%d %d\n", 1, i);
for (int i = n / 2 + 1 + 1; i <= n; i++)
printf("%d %d\n", i - n / 2 - 1, n / 2 + 1);
}
return 0;
if (n == 1)
{
puts("1\n1 1");
return 0;
}
printf("%d\n", ((n + 1) >> 1) + 1 - (n & 1));
for (int i = 1; i <= n; i++)
printf("%d %d\n", (i + 1) >> 1, ((i + 1) >> 1) + 1 - (i & 1));
return 0;
}

@ -0,0 +1,48 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
int a[N], b[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
for (int i = 0; i < n; i++) scanf("%d", b + i);
multiset<int> A{a, a + n}, B{b, b + n};
deque<int> q{b, b + n};
int zcnt = count(b, b + n, 0);
int opcnt = 0;
while (zcnt)
{
for (auto i : q)
printf("%2d ", i);
puts("");
if (A.count(q.back() + 1))
{
A.erase(q.back() + 1);
q.push_back(q.back() + 1);
B.insert(q.back() + 1);
if (q.front() == 0) zcnt--;
A.insert(q.front());
B.erase(q.front());
q.pop_front();
opcnt++;
}
else
{
A.erase(A.begin());
q.push_back(0);
B.insert(0);
zcnt++;
if (q.front() == 0) zcnt--;
A.insert(q.front());
B.erase(q.front());
q.pop_front();
opcnt++;
}
}
printf("%d", opcnt);
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
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++\\8.3.0\\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)
add_executable(P06 P06.cpp)
add_executable(P07 P07.cpp)
add_executable(P08 P08.cpp)
add_executable(P09 P09.cpp)
add_executable(P10 P10.cpp)
add_executable(P11 P11.cpp)
add_executable(P12 P12.cpp)
add_executable(P13 P13.cpp)

@ -0,0 +1,23 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 505, M = N * N;
int a[N], b[M];
int main()
{
int n, k;
scanf("%d%d", &n, &k);
for (int i = 0; i < n; i++)
scanf("%d", a + i);
int cnt = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
b[cnt++] = a[i] + a[j];
sort(b, b + cnt);
long long ans = 0;
for (int i = cnt - k; i < cnt; i++)
ans += b[i];
printf("%lld", ans);
return 0;
}

@ -0,0 +1,51 @@
#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 a[2][N];
int vis[2][N];
pair<int, int> que[N];
int rmost(int x)
{
int h = 0, t = 0, ans = x;
for (que[t++] = {!a[0][x], x}; h ^ t; h++)
{
auto x = que[h];
ans = max(ans, x.second);
if (a[x.first][x.second + 1]) que[t++] = {x.first, x.second + 1}, vis[x.first][x.second + 1] = true;
if (a[!x.first][x.second] && !vis[!x.first][x.second]) que[t++] = {!x.first, x.second}, vis[!x.first][x.second] = true;
}
return ans;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &a[0][i]);
for (int i = 0; i < n; i++)
scanf("%d", &a[1][i]);
int l = 0, r = n;
while (a[0][l] == 0 && a[1][l] == 0) l++;
while (a[0][r] == 0 && a[1][r] == 0) r--;
int ans = 0;
while (l < r)
{
int t = rmost(l), t2;
if (t == r) break;
for (t2 = t + 1; t2; t2++)
if (a[0][t2] | a[1][t2])
break;
if ((a[0][t] == 1 && a[0][t2] == 1) || (a[1][t] == 1 && a[1][t2] == 1))
ans += t2 - t - 1;
else
{
ans += t2 - t;
a[0][t2] = a[1][t2] = 1;
}
l = t2;
}
printf("%d", ans);
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
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;
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
long long a, b, x, cnt = 0;
scanf("%lld%lld%lld", &x, &a, &b);
for (long long i = 1; i <= a; i++)
for (long long j = 1; j <= b; j++)
if (x / i * j == x * j / i)
{
printf("dbg: %lld %lld %lld %lld\n", x, i, j, x / i * j);
cnt++;
}
printf("%lld\n", cnt);
}
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,10 @@
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(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)

@ -0,0 +1,54 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll calc2(ll id)
{
//return log2l(id + 1) + 1;
int ret = 0;
while ((1ll << ret) < id + 2) ret++;
return ret;
}
bool isPrefix(ll a, ll b)
{
if (a == 0) return true;
for (; b; b >>= 1)
if (a == b) return true;
return false;
}
int main()
{
ll m, k, q, op, x;
scanf("%lld%lld%lld", &m, &k, &q);
set<ll> rm;
if (m == 1)
while (q--)
{
scanf("%lld%lld", &op, &x);
if (op == 1)
rm.insert(x);
if (op == 2)
rm.erase(x);
printf("%lld\n", rm.empty() ? k : *rm.begin());
}
if (m == 2)
while (q--)
{
scanf("%lld%lld", &op, &x);
if (op == 1)
rm.insert(x);
if (op == 2)
rm.erase(x);
ll cnt = (1ll << k) - 1;
for (auto ite = rm.begin(); ite != rm.end(); ++ite)
{
bool flag = true;
for (auto ite2 = rm.begin(); ite2 != ite && flag; ++ite2)
flag = !isPrefix(*ite2 + 1, *ite + 1);
if (flag) cnt -= (1ll << (k - calc2(*ite) + 1)) - 1;
}
printf("%lld\n", cnt);
}
return 0;
}

@ -0,0 +1,27 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 105;
const ll mod = 1e9 + 7;
ll a[N];
ll f(ll l, ll r)
{
ll max1 = numeric_limits<ll>::min();
for (ll x = l; x <= r; x++)
max1 = max(max1, (r - x + 1) * *max_element(a + l, a + x + 1));
return max1;
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", a + i);
ll ans = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
ans = (ans + f(i, j)) % mod;
printf("%lld", ans);
return 0;
}

@ -0,0 +1,21 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 50;
const ll mod = 1e9 + 7;
ll a[N];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%lld", a + i);
ll ans = 0;
unordered_multiset<ll> S{a, a + n};
for (int i = 0; i < n; i++)
{
}
printf("%lld", ans);
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,10 @@
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(P1 P1.cpp)
add_executable(P2 P2.cpp)
add_executable(P3 P3.cpp)
add_executable(P4 P4.cpp)

@ -0,0 +1,21 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 60;
char s[N];
int main()
{
scanf("%s", s);
int n = strlen(s);
for (int i = 0, j = n; i < j;)
if (s[i++] == s[--j]) return puts("NO"), 0;
stack<char> st;
for (int i = 0; i < n; i++)
if (!st.empty() && st.top() == '(' && s[i] == ')')
st.pop();
else
st.push(s[i]);
puts(st.empty() ? "YES" : "NO");
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;
typedef long long ll;
const int N = 105;
int a[N], b[N];
ll f(int i, int x)
{
return 1ll * (x - a[i]) * (x - a[i]) + b[i];
}
ll g(int x, int n)
{
ll mx;
memset(&mx, 0x3f, sizeof(mx));
for (int i = 1; i <= n; i++)
mx = min(mx, f(i, x));
return mx;
}
int main()
{
int n, q;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
for (int i = 1; i <= n; i++) scanf("%d", b + i);
scanf("%d", &q);
while (q--)
{
int x;
scanf("%d", &x);
printf("%lld ", g(x, n));
}
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;
typedef long long ll;
const int N = 5050;
int a[N], b[N];
ll f(int i, int x)
{
return 1ll * (x - a[i]) * (x - a[i]) + b[i];
}
ll g(int x, int n)
{
ll mx;
memset(&mx, 0x3f, sizeof(mx));
for (int i = 1; i <= n; i++)
mx = min(mx, f(i, x));
return mx;
}
int main()
{
int n, q;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
for (int i = 1; i <= n; i++) scanf("%d", b + i);
scanf("%d", &q);
while (q--)
{
int x;
scanf("%d", &x);
printf("%lld ", g(x, n));
}
return 0;
}

@ -0,0 +1,32 @@
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 50;
int a[N], b[N];
int main()
{
int n, q;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
for (int i = 1; i <= n; i++) scanf("%d", b + i);
auto mm = minmax_element(b + 1, b + n + 1);
int rg = sqrt(*mm.second - *mm.first) / 4, po = 1;
scanf("%d", &q);
ll inf;
memset(&inf, 0x3f, sizeof(inf));
while (q--)
{
int x;
scanf("%d", &x);
ll mx = inf;
while (a[po] < x && po <= n) po++;
int st = max(1, po - rg), ed = min(n, po + rg);
for (int i = st; i <= ed; i++)
mx = min(mx, 1ll * (x - a[i]) * (x - a[i]) + b[i]);
printf("%lld ", mx);
}
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++\\8.3.0\\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)
add_executable(P06 P06.cpp)
add_executable(P07 P07.cpp)
add_executable(P08 P08.cpp)
add_executable(P09 P09.cpp)
add_executable(P10 P10.cpp)
add_executable(P11 P11.cpp)
add_executable(P12 P12.cpp)
add_executable(P13 P13.cpp)

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,25 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50005;
const int mod = 192600817;
ll f[N];
int main()
{
f[1] = f[2] = 1;
for (int i = 3; i < N; i++) f[i] = (f[i - 1] + f[i - 2]) % mod;
for (int i = 1; i < N; i++) f[i] = f[i] * f[i] % mod;
for (int i = 1; i < N; i++) f[i] = (f[i] + f[i - 1]) % mod;
for (int Q, a, b, c, d; ~scanf("%d", &Q);)
while (Q--)
{
scanf("%d%d%d%d", &a, &b, &c, &d);
b += a << 2;
d += c << 2;
if (b > d) swap(b, d);
printf("%lld\n", (f[d+1] - f[b] + mod) % mod);
}
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;
const int N = 15e4 + 40;
int lst[N];
int vis[1044650];
int str[256];
bool isPigeon(int x, int c)
{
while (x > 1)
{
if (vis[x] == c) return false;
vis[x] = c;
int len = 0;
for (; x; x /= 10)
str[len++] = x % 10;
for (int i = 0; i < len; i++)
x += str[i] * str[i];
}
return true;
}
int main()
{
int rs = 0;
for (int i = 1; rs < N; i++)
if (isPigeon(i, i))
lst[rs++] = i;
int Q, k;
scanf("%d", &Q);
while (Q--)
scanf("%d", &k), printf("%d\n", lst[k - 1]);
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,86 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 6;
const double EPS = 1e-8;
double a[10][10];
int solve(bool l[], double ans[], const int &n)
{
int res = 0, r = 0;
for (int i = 0; i < n; ++i) l[i] = false;
for (int i = 0; i < n; ++i)
{
for (int j = r; j < n; ++j)
if (fabs(a[j][i]) > EPS)
{
for (int k = i; k <= n; ++k) swap(a[j][k], a[r][k]);
break;
}
if (fabs(a[r][i]) < EPS)
{
++res;
continue;
}
for (int j = 0; j < n; ++j)
if (j != r && fabs(a[j][i]) > EPS)
{
double tmp = a[j][i] / a[r][i];
for (int k = i; k <= n; ++k) a[j][k] -= tmp * a[r][k];
}
l[i] = true, ++r;
}
for (int i = 0; i < n; ++i)
if (l[i])
for (int j = 0; j < n; ++j)
if (fabs(a[j][i]) > 0) ans[i] = a[j][n] / a[j][i];
return res;
}
int main()
{
int T, Q;
scanf("%d", &T);
while (T--)
{
int x1, y1, x2, y2, x3, y3;
int x4, y4, x5, y5, x6, y6;
scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3);
scanf("%d%d%d%d%d%d", &x4, &y4, &x5, &y5, &x6, &y6);
bool l[MAXN];
double ans[MAXN];
memset(l, 0, sizeof l);
memset(ans, 0, sizeof ans);
memset(a, 0, sizeof a);
a[0][0] = x1;
a[0][2] = y1;
a[0][6] = x4;
a[1][1] = x1;
a[1][3] = y1;
a[1][6] = y4;
a[2][0] = x2;
a[2][2] = y2;
a[2][6] = x5;
a[3][1] = x2;
a[3][3] = y2;
a[3][6] = y5;
a[4][0] = x3;
a[4][2] = y3;
a[4][6] = x6;
a[5][1] = x3;
a[5][3] = y3;
a[5][6] = y6;
solve(l, ans, MAXN);
for (int i = 0; i < MAXN; i++)
printf("%c %d %.4lf\n", 'a' + i, l[i], ans[i]);
scanf("%d", &Q);
while (Q--)
{
int x, y;
scanf("%d%d", &x, &y);
printf("%.2lf %.2lf\n", ans[0] * x + ans[2] * y, ans[1] * x + ans[3] * y);
}
}
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,59 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long mat[6][6];
const int mod = 123456789;
const size_t sz = sizeof(long long) * 36;
void mul(mat a, mat b)
{
mat c;
memset(c, 0, sz);
for (int i = 0; i < 6; i++)
for (int j = 0; j < 6; j++)
for (int k = 0; k < 6; k++)
c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % mod;
memcpy(a, c, sz);
}
void fpow(mat ret, mat a, long long b)
{
memset(ret, 0, sz);
for (int i = 0; i < 6; i++) ret[i][i] = 1;
for (; b; b >>= 1, mul(a, a))
if (b & 1)
mul(ret, a);
}
int main()
{
int T;
long long n;
scanf("%d", &T);
while (T--)
{
scanf("%lld", &n);
if (n <= 2)
printf("%lld\n", n);
else
{
mat b = {
{1, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 0},
{8, 0, 0, 0, 0, 0},
{4, 0, 0, 0, 0, 0},
{2, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0}};
mat a = {
{0, 1, 0, 0, 0, 0},
{2, 1, 1, 3, 3, 1},
{0, 0, 1, 3, 3, 1},
{0, 0, 0, 1, 2, 1},
{0, 0, 0, 0, 1, 1},
{0, 0, 0, 0, 0, 1}};
mat ret;
fpow(ret, a, n - 2);
mul(ret, b);
printf("%lld\n", ret[1][0]);
}
}
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,8 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}

@ -0,0 +1,19 @@
def atoi(x):
if x == '':
return 0
else:
return int(x)
_ = int(input())
s = input()
n = len(s)
l = r = n // 2
while l >= 0 and s[l] == '0':
l -= 1
while r < n and s[r] == '0':
r += 1
if l == r:
print(min(atoi(s[:sp]) + atoi(s[sp:]) for sp in [n // 2, (n + 1) // 2]))
else:
print(min(atoi(s[:sp]) + atoi(s[sp:]) for sp in [l, r]))

@ -0,0 +1,13 @@
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(P01 P01.cpp)
add_executable(P02 P02.cpp)
add_executable(P03 P03.cpp)
add_executable(P04 P04.cpp)
add_executable(P05 P05.cpp)
add_executable(P06 P06.cpp)
add_executable(P07 P07.cpp)

@ -0,0 +1,14 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long x, y, z;
cin >> x >> y >> z;
if (x + y < z)
cout << "0 0";
else
cout << (x + y) / z<<" " << max(min(((x + y) / z - x / z) * z - y, ((x + y) / z - y / z) * z - x), 0ll);
return 0;
}

@ -0,0 +1,25 @@
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50005;
const int mod = 192600817;
ll f[N];
int main()
{
f[1] = f[2] = 1;
for (int i = 3; i < N; i++) f[i] = (f[i - 1] + f[i - 2]) % mod;
for (int i = 1; i < N; i++) f[i] = f[i] * f[i] % mod;
for (int i = 1; i < N; i++) f[i] = (f[i] + f[i - 1]) % mod;
for (int Q, a, b, c, d; ~scanf("%d", &Q);)
while (Q--)
{
scanf("%d%d%d%d", &a, &b, &c, &d);
b += a << 2;
d += c << 2;
if (b > d) swap(b, d);
printf("%lld\n", (f[d+1] - f[b] + mod) % mod);
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save