Fri, 01 Nov 2019 09:07:08 GMT
parent
ebb55dd95a
commit
3fc96547c2
@ -1,68 +0,0 @@
|
||||
{
|
||||
"python.formatting.provider": "yapf",
|
||||
"files.associations": {
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"complex": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"csetjmp": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cuchar": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"fstream": "cpp",
|
||||
"functional": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"memory": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ratio": "cpp",
|
||||
"scoped_allocator": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"thread": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp",
|
||||
"valarray": "cpp"
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build current",
|
||||
"type": "shell",
|
||||
"command": "g++",
|
||||
"args": [
|
||||
"-std=c++2a",
|
||||
"-Wall",
|
||||
"-g",
|
||||
"${file}"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
int main()
|
||||
{
|
||||
int a[3];
|
||||
CLR(a);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const double eps = 1e-8;
|
||||
int cmp(double x)
|
||||
{
|
||||
if (x > eps)
|
||||
return 1;
|
||||
if (x < -eps)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
typedef struct
|
||||
{
|
||||
double x, y;
|
||||
} Base2D, Point, Vector;
|
||||
typedef const Point &CBase2DRef;
|
||||
typedef const Point &CPointRef;
|
||||
typedef const Vector &CVectorRef;
|
||||
inline Base2D operator+(CBase2DRef l, CBase2DRef r) { return {l.x + r.x, l.y + r.y}; }
|
||||
inline Base2D operator-(CBase2DRef l, CBase2DRef r) { return {l.x - r.x, l.y - r.y}; }
|
||||
inline Base2D operator*(CBase2DRef l, double r) { return {l.x * r, l.y * r}; }
|
||||
inline double cross(CVectorRef l, CVectorRef r) { return l.x * r.y - l.y * r.x; }
|
||||
inline double square(double x) { return x * x; }
|
||||
inline double dis2(CPointRef l, CPointRef r) { return square(r.x - l.x) + square(r.y - l.y); }
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
double ox, oy, r, ax, ay, vx, vy, bx, by;
|
||||
scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf", &ox, &oy, &r, &ax, &ay, &vx, &vy, &bx, &by);
|
||||
Vector dir = {vx, vy};
|
||||
Point o = {ox, oy}, a = {ax, ay}, b = {bx, by};
|
||||
bool flag = false;
|
||||
Vector oa = a - o, ba = a - b, bo = o - b;
|
||||
double fx = (bx - ax) / vx, fy = (by - ay) / vy;
|
||||
if (cmp(fx) == 1 && cmp(fx - fy) == 0) // Hit
|
||||
{
|
||||
if (cross(oa, dir) == 1 || cmp(cross(ba, bo)) <= 0 || abs(cross(oa, bo) / sqrt(dis2(ba, {0, 0}))) >= r)
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
double dis = abs(cross(oa, oa + dir) / sqrt(dis2(dir, {0, 0})));
|
||||
if (dis <= r)
|
||||
{
|
||||
// get first intersect
|
||||
double disInCircle = sqrt(r * r - dis * dis);
|
||||
double disOutCircle = sqrt(dis2(oa, {0, 0}) - dis * dis) - disInCircle;
|
||||
double scale = disOutCircle / sqrt(dis2(dir, {0, 0}));
|
||||
Point intersect = a + dir * scale;
|
||||
// mirror the line
|
||||
double A = intersect.y - o.y, B = o.x - intersect.x, C = intersect.x * o.y - o.x * intersect.y;
|
||||
double k = -2 * (A * a.x + B * a.y + C) / (A * A + B * B);
|
||||
Point am = {a.x + k * A, a.y + k * B};
|
||||
Vector dir2 = am - intersect;
|
||||
fx = (b.x - intersect.x) / dir2.x, fy = (b.y - intersect.y) / dir2.y;
|
||||
if (cmp(fx) == 1 && cmp(fx - fy) == 0)
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
printf("Case #%d: %s\n", t, flag ? "Yes" : "No");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
char s[1050];
|
||||
int pre[256];
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
scanf("%s", s);
|
||||
memset(pre, -1, sizeof(pre));
|
||||
unsigned ans = -1;
|
||||
int n = strlen(s);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (pre[s[i]] != -1)
|
||||
ans = min<unsigned>(ans, i - pre[s[i]]);
|
||||
pre[s[i]] = i;
|
||||
}
|
||||
|
||||
printf("Case #%d: %d\n", t, ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 1e5 + 50;
|
||||
char a[N];
|
||||
vector<int> v;
|
||||
inline ll square(ll x) { return x * x; }
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
v.clear();
|
||||
scanf("%s", a);
|
||||
int n = strlen(a);
|
||||
int curLen = 1;
|
||||
for (int i = 1; i < n; i++)
|
||||
{
|
||||
if (a[i - 1] == a[i])
|
||||
curLen++;
|
||||
else
|
||||
v.push_back(curLen), curLen = 1;
|
||||
}
|
||||
v.push_back(curLen);
|
||||
/*for (int i : v)
|
||||
cout << i << " ";
|
||||
cout << endl;*/
|
||||
ll ans_base = accumulate(v.begin(), v.end(), 0ll, [](ll pr, ll x) {
|
||||
return pr + x * x;
|
||||
});
|
||||
ll ans = ans_base;
|
||||
if (v[0] == 1)
|
||||
ans = max(ans, ans_base - 1 - square(v[1]) + square(1 + v[1]));
|
||||
if (v[v.size() - 1] == 1)
|
||||
ans = max(ans, ans_base - 1 - square(v[v.size() - 2]) + square(1 + v[v.size() - 2]));
|
||||
for (int i = 1; i < v.size() - 1; i++)
|
||||
if (v[i] == 1)
|
||||
ans = max(ans, ans_base - 1 - square(v[i - 1]) - square(v[i + 1]) + square(v[i - 1] + 1 + v[i + 1]));
|
||||
for (int i = 1; i < v.size(); i++)
|
||||
ans = max(ans, ans_base - square(v[i - 1]) - square(v[i]) + square(v[i - 1] + 1) + square(v[i] - 1));
|
||||
for (int i = 1; i < v.size(); i++)
|
||||
ans = max(ans, ans_base - square(v[i - 1]) - square(v[i]) + square(v[i - 1] - 1) + square(v[i] + 1));
|
||||
printf("Case #%d: %lld\n", t, ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
|
||||
ll calc(ll x, ll y)
|
||||
{
|
||||
if (x > y)
|
||||
swap(x, y);
|
||||
ll ans = 1;
|
||||
for (ll i = 1; i * i <= y; i++)
|
||||
if (y % i == 0)
|
||||
{
|
||||
if (y == i * (1 + x / gcd(x, i)))
|
||||
ans += calc(x, i);
|
||||
if (i * i != y)
|
||||
{
|
||||
ll j = y / i;
|
||||
if (y == j * (1 + x / gcd(x, j)))
|
||||
ans += calc(x, j);
|
||||
}
|
||||
}
|
||||
//printf("calc(%lld, %lld) = %lld\n", x, y, ans);
|
||||
return ans;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int T, x, y;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
scanf("%d%d", &x, &y), printf("Case #%d: %lld\n", t, calc(x, y));
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 1e5 + 50;
|
||||
ll f[N];
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
printf("Case #%d:\n", t);
|
||||
int q, m, op, x;
|
||||
scanf("%d%d", &q, &m);
|
||||
ll ans = 1;
|
||||
for (int i = 1; i <= q; i++)
|
||||
{
|
||||
scanf("%d%d", &op, &x);
|
||||
if (op == 1)
|
||||
ans = ans * (f[i] = x) % m;
|
||||
else
|
||||
{
|
||||
ans = f[x] = f[i] = 1;
|
||||
for (int j = 1; j < i; j++)
|
||||
ans = ans * f[j] % m;
|
||||
}
|
||||
printf("%lld\n", ans);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
inline double sq(double x) { return x * x; }
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
double ax, ay, bx, by, cx, cy;
|
||||
scanf("%lf%lf%lf%lf%lf%lf", &ax, &ay, &bx, &by, &cx, &cy);
|
||||
double mx = (bx + cx) / 2, my = (by + cy) / 2;
|
||||
double ac = sqrt(sq(ax - cx) + sq(ay - cy));
|
||||
double bc = sqrt(sq(bx - cx) + sq(by - cy));
|
||||
double am = sqrt(sq(ax - mx) + sq(ay - my));
|
||||
double r = bc * ac / am / 2;
|
||||
double alpha = asin(am / ac) * 2;
|
||||
double arc = alpha * r;
|
||||
printf("Case #%d: %.4lf\n", t, am + arc);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 105;
|
||||
int L[N], R[N];
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
int n, a, b, l;
|
||||
scanf("%d%d%d%d", &n, &a, &b, &l);
|
||||
for (int i = 0; i < n; i++)
|
||||
scanf("%d%d", L + i, R + i);
|
||||
ll cur = 0, ans = 0;
|
||||
int pos = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cur += b * (L[i] - pos) - a * (R[i] - L[i]);
|
||||
ans = max(ans, -cur);
|
||||
pos = R[i];
|
||||
}
|
||||
printf("Case #%d: %lld\n", t, ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
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;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
ll c, k1, k2, b1;
|
||||
for (int t = 1; ~scanf("%lld%lld%lld%lld", &c, &k1, &b1, &k2); t++)
|
||||
{
|
||||
printf("Case #%d:\n", t);
|
||||
bool flag = 0;
|
||||
for (ll i = 1, a, b; i < c; i++)
|
||||
if (fpow(a = i, k1, c) == fpow(b = c - fpow(a, k1 + b1, c), k2, c))
|
||||
printf("%lld %lld\n", a, b), flag = true;
|
||||
if (!flag)
|
||||
puts("-1");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
int main()
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
char ss[505][2050];
|
||||
bool vis[505];
|
||||
int main()
|
||||
{
|
||||
int T, n;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
CLR(vis);
|
||||
scanf("%d", &n);
|
||||
for (int i = 1; i <= n; i++)
|
||||
scanf("%s", ss[i]);
|
||||
int ans = -1;
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j < i; j++)
|
||||
{
|
||||
if (vis[j])
|
||||
continue;
|
||||
if (strstr(ss[i], ss[j]) != nullptr)
|
||||
vis[j] = true;
|
||||
else
|
||||
ans = i;
|
||||
}
|
||||
printf("Case #%d: %d\n", t, ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
|
||||
int main()
|
||||
{
|
||||
int T, n, a, b;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
scanf("%d%d%d", &n, &a, &b), printf("Case #%d: %s\n", t, (n / gcd(b, a) & 1) ? "Yuwgna" : "Iaka");
|
||||
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 OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
const int maxn = 1e5 + 5;
|
||||
int n, m;
|
||||
int t[maxn];
|
||||
vector<int> gid[maxn];
|
||||
vector<int> grp[maxn];
|
||||
ll dis1[maxn], dis2[maxn];
|
||||
void dijkstra(int S, ll *dis)
|
||||
{
|
||||
struct heap_node
|
||||
{
|
||||
int u;
|
||||
ll d;
|
||||
OPL(heap_node, rhs) { return d > rhs.d; }
|
||||
};
|
||||
priority_queue<heap_node> H;
|
||||
H.push({S, dis[S] = 0});
|
||||
for (heap_node cur; !H.empty(); H.pop())
|
||||
for (int g : gid[(cur = H.top()).u])
|
||||
for (int to : grp[g])
|
||||
if (dis[to] > dis[cur.u] + t[g])
|
||||
H.push({to, dis[to] = dis[cur.u] + t[g]});
|
||||
}
|
||||
int main()
|
||||
{
|
||||
|
||||
int T;
|
||||
cin >> T;
|
||||
for (int _ = 1; _ <= T; _++)
|
||||
{
|
||||
scanf("%d%d", &n, &m);
|
||||
memset(dis1, 0x3f, sizeof(ll) * (n + 2));
|
||||
memset(dis2, 0x3f, sizeof(ll) * (n + 2));
|
||||
for (int i = 1; i <= n; i++)
|
||||
gid[i].clear();
|
||||
for (int i = 0, cnt; i < m; i++)
|
||||
{
|
||||
grp[i].clear();
|
||||
scanf("%d%d", t + i, &cnt);
|
||||
for (int j = 0, x; j < cnt; j++)
|
||||
{
|
||||
scanf("%d", &x);
|
||||
gid[x].push_back(i);
|
||||
grp[i].push_back(x);
|
||||
}
|
||||
}
|
||||
dijkstra(1, dis1);
|
||||
dijkstra(n, dis2);
|
||||
ll mx = LLONG_MAX;
|
||||
for (int i = 1; i <= n; i++)
|
||||
mx = min(mx, max(dis1[i], dis2[i]));
|
||||
IFD
|
||||
{
|
||||
for (int i = 1; i <= n; i++)
|
||||
printf("%lld%c", dis1[i], " \n"[i == n]);
|
||||
for (int i = 1; i <= n; i++)
|
||||
printf("%lld%c", dis2[i], " \n"[i == n]);
|
||||
}
|
||||
printf("Case #%d: ", _);
|
||||
ll inf = *dis1 >> 1;
|
||||
if (mx >= inf)
|
||||
puts("Evil John");
|
||||
else
|
||||
{
|
||||
printf("%lld\n", mx);
|
||||
for (int i = 1; i <= n; i++)
|
||||
if (mx == max(dis1[i], dis2[i]))
|
||||
printf("%d ", i);
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
int T, n, m, k;
|
||||
int col[26], a[6][6];
|
||||
bool flag = false;
|
||||
void dfs(int st)
|
||||
{
|
||||
if (st == -1)
|
||||
{
|
||||
flag = true;
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < k; i++)
|
||||
if ((st + 2) / 2 < col[i])
|
||||
return;
|
||||
int x = st / m, y = st % m;
|
||||
for (int i = 0; i < k; i++)
|
||||
if (col[i] && a[x + 1][y] != i && a[x][y + 1] != i)
|
||||
{
|
||||
col[a[x][y] = i]--;
|
||||
dfs(st - 1);
|
||||
if (flag)
|
||||
return;
|
||||
col[i]++;
|
||||
a[x][y] = -1;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
NE1(a), flag = false;
|
||||
scanf("%d%d%d", &n, &m, &k);
|
||||
for (int i = 0; i < k; i++)
|
||||
scanf("%d", col + i);
|
||||
dfs(n * m - 1);
|
||||
printf("Case #%d:\n", t);
|
||||
if (flag)
|
||||
{
|
||||
puts("YES");
|
||||
for (int i = 0; i < n; i++)
|
||||
for (int j = 0; j < m; j++)
|
||||
printf("%d%c", a[i][j] + 1, " \n"[j == m - 1]);
|
||||
}
|
||||
else
|
||||
puts("NO");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef long long ll, i64;
|
||||
|
||||
const int N = 1 << 20;
|
||||
int a[42];
|
||||
ll f[42][N | 1];
|
||||
int main()
|
||||
{
|
||||
**f = 1;
|
||||
int T, n, m;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
scanf("%d%d", &n, &m);
|
||||
for (int i = 1; i <= n; i++)
|
||||
scanf("%d", a + i);
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 0; j < N; j++)
|
||||
f[i][j] = f[i - 1][j ^ a[i]] + f[i - 1][j];
|
||||
printf("Case #%d: %lld\n", t, accumulate(f[n] + m, f[n] + N, 0ll));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,91 @@
|
||||
#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 long long ll, i64;
|
||||
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;
|
||||
|
||||
constexpr double eps = 1e-8;
|
||||
int sgn(double x)
|
||||
{
|
||||
if (x > eps)
|
||||
return 1;
|
||||
if (x < -eps)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename T, typename = enable_if_arithmetic<T>>
|
||||
struct Point
|
||||
{
|
||||
T x, y;
|
||||
Point OPX(-, Point, rhs) const { return {x - rhs.x, y - rhs.y}; }
|
||||
T OPX(*, Point, rhs) const { return x * rhs.x + y * rhs.y; }
|
||||
T OPX (^, Point, rhs) const { return x * rhs.y - y * rhs.x; }
|
||||
T len2() const { return x * x + y * y; }
|
||||
double len() const { return sqrt(len2()); }
|
||||
};
|
||||
template <typename T>
|
||||
struct Line
|
||||
{
|
||||
Point<T> s, e;
|
||||
T len2() const { return (s - e).len2(); }
|
||||
double len() const { return (s - e).len(); }
|
||||
bool contains(CRP(Point<T>, p)) const { return sgn((s - p) ^ (e - p)) == 0 && sgn((s - p) * (e - p)) <= 0; }
|
||||
};
|
||||
template <typename T>
|
||||
struct Circle
|
||||
{
|
||||
Point<T> c;
|
||||
T r;
|
||||
};
|
||||
#define Point Point<double>
|
||||
#define norm len
|
||||
const double pi = acos(-1);
|
||||
double area(Point ap, double ra, Point bp, double rb)
|
||||
{
|
||||
double a = (ap - bp).norm(), b = ra, c = rb;
|
||||
if (b < eps || c < eps)
|
||||
return 0;
|
||||
if (a < rb - ra + eps)
|
||||
return pi * ra * ra;
|
||||
if (a < ra - rb + eps)
|
||||
return pi * rb * rb;
|
||||
if (a < eps)
|
||||
return pi * sqrt(min(ra, rb));
|
||||
if (a > ra + rb - eps)
|
||||
return 0;
|
||||
double cta1 = acos((a * a + b * b - c * c) / 2 / (a * b));
|
||||
double cta2 = acos((a * a + c * c - b * b) / 2 / (a * c));
|
||||
double s1 = ra * ra * cta1 - ra * ra * sin(cta1) * (a * a + b * b - c * c) / 2 / (a * b);
|
||||
double s2 = rb * rb * cta2 - rb * rb * sin(cta2) * (a * a + c * c - b * b) / 2 / (a * c);
|
||||
return s1 + s2;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int T;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
double r, R;
|
||||
Point p1, p2;
|
||||
scanf("%lf%lf%lf%lf%lf%lf", &r, &R, &p1.x, &p1.y, &p2.x, &p2.y);
|
||||
printf("Case #%d: %lf\n", t,
|
||||
area(p1, R, p2, R) - area(p1, r, p2, R) - area(p1, R, p2, r) + area(p1, r, p2, r));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define 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 long long ll, i64;
|
||||
const int N = 1e6 + 60;
|
||||
int a[N];
|
||||
int main()
|
||||
{
|
||||
int T, n;
|
||||
scanf("%d", &T);
|
||||
for (int t = 1; t <= T; t++)
|
||||
{
|
||||
scanf("%d", &n);
|
||||
for (int i = 1; i <= n; i++)
|
||||
scanf("%d", a + i);
|
||||
int mn = INT_MAX, ans = 0;
|
||||
for (int i = n; i; i--)
|
||||
if (a[i] < mn)
|
||||
mn = a[i];
|
||||
else
|
||||
ans++;
|
||||
printf("Case #%d: %d\n", t, ans);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
#define CRP(t, x) const t &x
|
||||
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
||||
#define FIL(x, v) memset(x, v, sizeof(x))
|
||||
#define CLR(x) FIL(x, 0)
|
||||
#define NE1(x) FIL(x, -1)
|
||||
#define INF(x) FIL(x, 0x3f)
|
||||
#ifndef _DEBUG
|
||||
#define _DEBUG 0
|
||||
#endif // !_DEBUG
|
||||
#define IFD if (_DEBUG)
|
||||
typedef int64_t ll, i64;
|
||||
typedef uint64_t ull, u64;
|
||||
const int N = 1005 * 1005;
|
||||
const double eps = 1e-8;
|
||||
int a[1605], x[45];
|
||||
int main()
|
||||
{
|
||||
int T, n;
|
||||
double p;
|
||||
scanf("%d", &T);
|
||||
while (T--)
|
||||
{
|
||||
scanf("%d%lf", &n, &p);
|
||||
for (int i = 1; i <= n; i++)
|
||||
cin >> x[i];
|
||||
a[0] = 0;
|
||||
int co = 1;
|
||||
for (int i = 0; i <= n; i++)
|
||||
for (int j = i + 1; j <= n; j++)
|
||||
a[co++] = x[i] + x[j];
|
||||
sort(a, a + co);
|
||||
n = (1.0 - p < eps) ? n : (int)(p * pow(2, n));
|
||||
cout << a[n - 1] << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e5 + 50;
|
||||
int a[N];
|
||||
int main()
|
||||
{
|
||||
int n, k;
|
||||
scanf("%d%d", &n, &k);
|
||||
for (int i = 0; i < n; i++)
|
||||
scanf("%d", a + i);
|
||||
int ans = 0x3f3f3f3f;
|
||||
for (int i = 0; i <= n - k; i++)
|
||||
ans = min(ans, min(abs(a[i]) + a[i + k - 1] - a[i], abs(a[i + k - 1]) + a[i + k - 1] - a[i]));
|
||||
printf("%d", ans);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e5 + 50;
|
||||
typedef long long ll;
|
||||
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
|
||||
int a[N];
|
||||
int main()
|
||||
{
|
||||
int n, x;
|
||||
scanf("%d%d", &n, &x);
|
||||
for (int i = 0; i < n; i++)
|
||||
scanf("%d", a + i), a[i] = abs(a[i] - x);
|
||||
int g = *a;
|
||||
for (int i = 0; i < n; i++)
|
||||
g = gcd(g, a[i]);
|
||||
printf("%d", g);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 2e5 + 50;
|
||||
char s[N], t[N];
|
||||
char mp1[256], mp2[256];
|
||||
int main()
|
||||
{
|
||||
scanf("%s%s", s, t);
|
||||
for (char *ps = s, *pt = t; *ps; ps++, pt++)
|
||||
{
|
||||
if (mp1[*ps] == 0 && mp2[*pt] == 0)
|
||||
mp1[*ps] = *pt, mp2[*pt] = *ps;
|
||||
if (mp1[*ps] != *pt || mp2[*pt] != *ps)
|
||||
return puts("No"), 0;
|
||||
}
|
||||
return puts("Yes"), 0;
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 1e5 + 50;
|
||||
int a[N], cnt1[N], cnt2[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 += 2)
|
||||
cnt1[a[i]]++;
|
||||
for (int i = 1; i < n; i += 2)
|
||||
cnt2[a[i]]++;
|
||||
vector<pair<int, int>> v1(n), v2(n);
|
||||
v1.push_back({0, 0}), v2.push_back({0, 0});
|
||||
for (int i = 0; i < N; i++)
|
||||
if (cnt1[i])
|
||||
v1.push_back({cnt1[i], i});
|
||||
for (int i = 0; i < N; i++)
|
||||
if (cnt2[i])
|
||||
v2.push_back({cnt2[i], i});
|
||||
sort(v1.begin(), v1.end(), greater<pair<int, int>>());
|
||||
sort(v2.begin(), v2.end(), greater<pair<int, int>>());
|
||||
if (v1[0].second != v2[0].second)
|
||||
printf("%d", n - v1[0].first - v2[0].first);
|
||||
else
|
||||
printf("%d", min(n - v1[0].first - v2[1].first, n - v1[1].first - v2[0].first));
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
struct
|
||||
{
|
||||
int x, y, h;
|
||||
} a[105];
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
scanf("%d", &n);
|
||||
for (int i = 0; i < n; i++)
|
||||
scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].h);
|
||||
for (int i = 0; i < n && a->h == 0; i++)
|
||||
if (a[i].h)
|
||||
iter_swap(a + i, a);
|
||||
for (int i = 0; i <= 100; i++)
|
||||
for (int j = 0; j <= 100; j++)
|
||||
{
|
||||
int pre = a->h + abs(i - a->x) + abs(j - a->y);
|
||||
bool flag = true;
|
||||
for (int k = 0; k < n && flag; k++)
|
||||
if (max(pre - abs(i - a[k].x) - abs(j - a[k].y), 0) != a[k].h)
|
||||
flag = false;
|
||||
if (flag)
|
||||
return printf("%d %d %d", i, j, pre), 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e5 + 50;
|
||||
struct
|
||||
{
|
||||
int p, y;
|
||||
} a[N];
|
||||
vector<pair<int, int>> v[N];
|
||||
int main()
|
||||
{
|
||||
int n, m;
|
||||
scanf("%d%d", &n, &m);
|
||||
for (int i = 0; i < m; i++)
|
||||
scanf("%d%d", &a[i].p, &a[i].y);
|
||||
for (int i = 0; i < m; i++)
|
||||
v[a[i].p].push_back({a[i].y, i});
|
||||
for (int i = 1; i <= n; i++)
|
||||
sort(v[i].begin(), v[i].end());
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 0; j < v[i].size(); j++)
|
||||
a[v[i][j].second].y = j + 1;
|
||||
for (int i = 0; i < m; i++)
|
||||
printf("%06d%06d\n", a[i].p, a[i].y);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
int m[] = {0, 3, 5, 7};
|
||||
int main()
|
||||
{
|
||||
ll n;
|
||||
scanf("%lld", &n);
|
||||
int cnt = 0;
|
||||
for (int i = 0;; i++)
|
||||
{
|
||||
ll cur = 0;
|
||||
bool b[4] = {0};
|
||||
char buf[20];
|
||||
int l = 0, x = i;
|
||||
do
|
||||
buf[l++] = x & 3, x >>= 2;
|
||||
while (x);
|
||||
for (int j = l - 1; j >= 0; j--)
|
||||
cur = cur * 10 + m[buf[j]], b[buf[j]] = true;
|
||||
if (cur > n)
|
||||
break;
|
||||
if (!b[0] && b[1] && b[2] && b[3])
|
||||
cnt++;
|
||||
}
|
||||
printf("%d", cnt);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 1e5 + 50;
|
||||
int a[N];
|
||||
int main()
|
||||
{
|
||||
int k, n;
|
||||
scanf("%d%d", &n, &k);
|
||||
for (int i = 0; i < n; i++)
|
||||
scanf("%d", a + i);
|
||||
sort(a, a + n);
|
||||
int ans = a[n - 1] - a[0];
|
||||
for (int i = k - 1; i < n; i++)
|
||||
ans = min(ans, a[i] - a[i - k + 1]);
|
||||
printf("%d", ans);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
int main()
|
||||
{
|
||||
int n, x, pre = 0, ans = 0;
|
||||
scanf("%d", &n);
|
||||
for (int i = 0; i < n; i++, pre = x)
|
||||
scanf("%d", &x), ans += max(0, x - pre);
|
||||
printf("%d", ans);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long ll;
|
||||
const int N = 1e5 + 50;
|
||||
int a[N];
|
||||
int main()
|
||||
{
|
||||
int n, m;
|
||||
ll ans = 0;
|
||||
scanf("%d%d", &n, &m);
|
||||
for (int i = 0; i < m; i++)
|
||||
scanf("%d", a + i);
|
||||
sort(a, a + m);
|
||||
for (int i = 1; i < m; i++)
|
||||
a[i - 1] = a[i] - a[i - 1];
|
||||
sort(a, a + m - 1, greater<int>());
|
||||
for (int i = n - 1; i < m - 1; i++)
|
||||
ans += a[i];
|
||||
printf("%lld", ans);
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
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,11 @@
|
||||
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()
|
||||
@ -0,0 +1,18 @@
|
||||
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)
|
||||
@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
uint8_t encode[48] = {
|
||||
0x96, 0x62, 0x53, 0x43, 0x6D, 0xF2, 0x8F, 0xBC,
|
||||
0x16, 0xEE, 0x30, 0x05, 0x78, 0x00, 0x01, 0x52,
|
||||
0xEC, 0x08, 0x5F, 0x93, 0xEA, 0xB5, 0xC0, 0x4D,
|
||||
0x50, 0xF4, 0x53, 0xD8, 0xAF, 0x90, 0x2B, 0x34,
|
||||
0x81, 0x36, 0x2C, 0xAA, 0xBC, 0x0E, 0x25, 0x8B,
|
||||
0xE4, 0x8A, 0xC6, 0xA2, 0x81, 0x9F, 0x75, 0x55};
|
||||
|
||||
int main()
|
||||
{
|
||||
for (int j = 0; j < 6; j++)
|
||||
{
|
||||
uint64_t x = *(uint64_t *)&encode[j << 3];
|
||||
for (int i = 0; i < 64; i++)
|
||||
if (x & 1)
|
||||
x = (x ^ 0xB0004B7679FA26B3uLL) >> 1 | (1ll << 63);
|
||||
else
|
||||
x >>= 1;
|
||||
char *pt = (char *)&x;
|
||||
for (int i = 0; i < 8; i++)
|
||||
putchar(pt[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,106 @@
|
||||
#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 long long ll, i64;
|
||||
|
||||
constexpr double eps = 1e-8;
|
||||
int sgn(double x)
|
||||
{
|
||||
if (x > eps)
|
||||
return 1;
|
||||
if (x < -eps)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
template <typename T, typename = enable_if_arithmetic<T>>
|
||||
struct Point
|
||||
{
|
||||
T x, y;
|
||||
Point OPX(-, Point, rhs) const { return {x - rhs.x, y - rhs.y}; }
|
||||
T OPX(*, Point, rhs) const { return x * rhs.x + y * rhs.y; }
|
||||
T OPX (^, Point, rhs) const { return x * rhs.y - y * rhs.x; }
|
||||
T len2() const { return x * x + y * y; }
|
||||
double len() const { return sqrt(len2()); }
|
||||
};
|
||||
template <typename T>
|
||||
struct Line
|
||||
{
|
||||
Point<T> s, e;
|
||||
T len2() const { return (s - e).len2(); }
|
||||
double len() const { return (s - e).len(); }
|
||||
bool contains(CRP(Point<T>, p)) const { return sgn((s - p) ^ (e - p)) == 0 && sgn((s - p) * (e - p)) <= 0; }
|
||||
};
|
||||
#define Point Point<double>
|
||||
#define Line Line<double>
|
||||
double area(CRP(Point, p1), CRP(Point, p2), CRP(Point, p3))
|
||||
{
|
||||
return abs((p3 - p1) ^ (p2 - p1));
|
||||
}
|
||||
int main2()
|
||||
{
|
||||
Point p[3], e;
|
||||
while (~scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y, &e.x, &e.y))
|
||||
{
|
||||
Line ls[3] = {{p[1], p[2]}, {p[0], p[2]}, {p[0], p[1]}};
|
||||
bool flag = true;
|
||||
for (int i = 0; i < 3 && flag; i++)
|
||||
if (ls[i].contains(e))
|
||||
{
|
||||
int l = (i + 2) % 3, r = (i + 1) % 3;
|
||||
int near = (e - p[l]).len2() < (e - p[r]).len2() ? l : r;
|
||||
int other = l + r - near;
|
||||
double len = ls[i].len() * ls[near].len() / 2 / (e - p[other]).len();
|
||||
double fulllen = ls[near].len();
|
||||
Point dif = p[i] - p[other];
|
||||
printf("%.12lf %.12lf\n", p[other].x + dif.x * len / fulllen, p[other].y + dif.y * len / fulllen);
|
||||
if (sgn(area(p[other], e, {p[other].x + dif.x * len / fulllen, p[other].y + dif.y * len / fulllen}) * 2 - area(p[0], p[1], p[2])))
|
||||
return -1;
|
||||
flag = false;
|
||||
}
|
||||
if (flag)
|
||||
puts("-1");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
Point p[3], e;
|
||||
while (~scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &p[0].x, &p[0].y, &p[1].x, &p[1].y, &p[2].x, &p[2].y, &e.x, &e.y))
|
||||
{
|
||||
Line ls[3] = {{p[1], p[2]}, {p[0], p[2]}, {p[0], p[1]}};
|
||||
bool flag = true;
|
||||
for (int i = 0; i < 3 && flag; i++)
|
||||
if (ls[i].contains(e))
|
||||
{
|
||||
int l = (i + 2) % 3, r = (i + 1) % 3;
|
||||
int near = (e - p[l]).len2() < (e - p[r]).len2() ? l : r;
|
||||
int other = l + r - near;
|
||||
double len = sqrt(ls[i].len2() * ls[near].len2() / 4 / (e - p[other]).len2());
|
||||
double fulllen = ls[near].len();
|
||||
Point dif = p[i] - p[other];
|
||||
printf("%.12lf %.12lf\n", p[other].x + dif.x * len / fulllen, p[other].y + dif.y * len / fulllen);
|
||||
if (sgn(area(p[other], e, {p[other].x + dif.x * len / fulllen, p[other].y + dif.y * len / fulllen}) * 2 - area(p[0], p[1], p[2])))
|
||||
return -1;
|
||||
flag = false;
|
||||
}
|
||||
if (flag)
|
||||
puts("-1");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2,
|
||||
"metadata": {
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
}
|
||||
},
|
||||
"orig_nbformat": 2,
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"npconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": 3
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": "array([[0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.],\n [0., 0., 0.]])"
|
||||
},
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"np.zeros((5,3))"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
#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 long long ll, i64;
|
||||
int main()
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef __TMPL_H_
|
||||
#define __TMPL_H_
|
||||
#include <iterator>
|
||||
template <typename T = int>
|
||||
class range
|
||||
{
|
||||
private:
|
||||
class range_iterator : std::iterator<std::forward_iterator_tag, T>
|
||||
{
|
||||
private:
|
||||
T val, step;
|
||||
public:
|
||||
range_iterator(T x, T sp) : val(x), step(sp) {}
|
||||
bool operator==(const range_iterator &rhs) const noexcept
|
||||
{
|
||||
if (step > 0) return val - step < rhs.val && val >= rhs.val;
|
||||
if (step < 0) return val - step > rhs.val && val <= rhs.val;
|
||||
return val == rhs.val;
|
||||
}
|
||||
bool operator!=(const range_iterator &rhs) const noexcept { return !(*this == rhs); }
|
||||
const auto &operator++() { return val += step, *this; }
|
||||
T &operator*() { return val; }
|
||||
} st, ed;
|
||||
|
||||
public:
|
||||
range(T ed) : range(0, ed, 1) {}
|
||||
range(T st, T ed, T sp = 1) : st(st, sp), ed(ed, sp) {}
|
||||
const range_iterator &begin() { return st; }
|
||||
const range_iterator &end() { return ed; }
|
||||
};
|
||||
#endif
|
||||
Loading…
Reference in new issue