# t1-快速多项式变换(FPT)

## ac代码

#include <bits/stdc++.h>
using namespace std;
long long n, m, a[1005];
int cnt;
int main() {
cin >> n >> m;
while (m > 0) {
a[ ++ cnt] = m % n;
m /= n;
}
printf("%d\n", cnt);
for (int i = 1; i <= cnt; i ++) printf("%lld ", a[i]);
return 0;
}

# t2-加特林轮盘赌

## 题解

$f[2][1]=p0*0+(1-p0)*f[2][2]$

$f[2][1]+f[2][2]=1$

$f[n][1]=(1-p0)*f[n][n]$
$f[n][1]+f[n][2]+...f[n][n]=1$

$f[n][k]->f[n][k-1]$

$f[n][k]->f[n-1][k-1]$

$f[n][k]=p0*f[n][k-1]+(1-p0)*f[n-1][k-1]$

## ac代码

#include <bits/stdc++.h>
#define db double
#define N 100005
using namespace std;
db f[2][N];
int n, k;
db p0;
int main() {
cin>> p0>> n>> k;
if (p0 == 0){
printf("%.10lf\n",0.0);
return 0;
}
f[1][1] = 1;
for (int i = 2; i <= n; i ++) {
db rate = 1, tmp = 0;
for (int j = 0; j <= i - 2; j ++) {
tmp += rate * f[(i - 1) % 2][i - j - 1];
rate *= (1 - p0);
}
rate *= (1 - p0);
tmp *= p0;
tmp /= (1 - rate);
f[i % 2][1] = (1 - p0) * tmp;
for (int j = 2; j <= i; j ++)
f[i % 2][j] = (1 - p0) * f[i % 2][j - 1] + p0 * f[(i - 1) % 2][j - 1];
f[i % 2][i] = tmp;
}
printf("%.10lf\n",f[n % 2][k]);
return 0;
}

# t3-东京夏日相会

## ac代码

#include <bits/stdc++.h>
#define N 20000005
#define db double
#define PI acos(-1)
using namespace std;
struct Point {
db x, y;
}a[N], o;
const db eps = 1e-4;
int tot, n;
db ri;
void create_point(db x, db y, db r) {
if (r == 0) a[++ tot] = (Point){x, y};
else {
db delta = max(360 * acos(1 - 0.004 / r) / PI, 1.0);
for (int i = 0; i < 360; i += delta) {
db alpha = i * PI / 180;
a[++ tot] = (Point){x + r * cos(alpha), y + r * sin(alpha)};
}
}
}
db calc(Point a, Point b) {
return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
void three_point(Point p1, Point p2, Point p3) {
db a = p2.y - p1.y, b = p3.y - p1.y, c = p2.x - p1.x, d = p3.x - p1.x, e = p2.x * p2.x + p2.y * p2.y - p1.x * p1.x - p1.y * p1.y, f = p3.x * p3.x + p3.y * p3.y - p1.x * p1.x - p1.y * p1.y ;
o.x = (a * f - b * e) / (2 * a * d - 2 * b * c);
o.y = (d * e - c * f) / (2 * a * d - 2 * b * c);
ri = calc(o, p1);
}
int main() {
scanf("%d", &n);
tot = 0;
for (int i = 1; i <= n; i ++) {
db x, y, r;
scanf("%lf%lf%lf", &x, &y, &r);
create_point(x, y, r);
}
random_shuffle(a + 1, a + 1 + tot);
o = a[1]; ri = 0;
for (int i = 2; i <= tot; i ++) {
if (calc(a[i], o) > ri + eps) {
o = a[i]; ri = 0;
for (int j = 1; j <= i - 1; j ++) {
if (calc(o, a[j]) > ri + eps) {
o.x = (a[i].x + a[j].x) / 2;
o.y = (a[i].y + a[j].y) / 2;
ri = calc(o, a[j]);
for (int k = 1; k <= j - 1; k ++) {
if (calc(o, a[k])>ri + eps) three_point(a[i], a[j], a[k]);
}
}
}
}
}
printf("%.2lf %.2lf %.2lf\n", o.x, o.y, ri);
return 0;
}

# t4-第二代图灵机

## 官方ac代码

//T4 std By Sinon
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <bitset>
#include <cstdlib>
#define IT set<node>::iterator
using namespace std;
const int MAXM = 150, MAXN = 100050;

char ch;
while(ch = getchar(), ch < '!'); x = ch - 48;
while(ch = getchar(), ch > '!') x = (x << 3) + (x << 1) + ch - 48;
}

void write(int x) {if(x > 9) write(x / 10); putchar(x % 10 + 48);}

struct node {
int l, r;
mutable int v;
node(int L, int R = -1, int V = 0) : l(L), r(R), v(V) {}
bool operator < (const node &o) const {
return l < o.l;
}
};

set <node> s;
int n, m, q, ap[MAXM], t[MAXN], tree[MAXN << 2], w[MAXN];
bool apt[MAXM];

int lowbit(int x) {return x & (-x);}

void update(int x, int val) {
for(; x <= n; t[x] += val, x += lowbit(x));
}
int query(int x) {
int res = 0;
for(; x > 0; res += t[x], x -= lowbit(x));
return res;
}
int ask(int l, int r) {return query(r) - query(l-1);}

void pushup(int i){tree[i] = max(tree[i << 1], tree[i << 1 | 1]);}

void updatemax(int i, int l, int r, int x, int val) {
if (l == r) {tree[i] = val; return;}
int mid = (l + r) / 2;
if (x <= mid) updatemax(i << 1, l, mid, x, val);
else updatemax(i << 1 | 1, mid + 1, r, x, val);
pushup(i);
}

int querymax(int i, int l, int r, int x, int y) {
if (x <= l && r <= y) return tree[i];
int mx = 0, mid = (l + r) / 2;
if (x <= mid) mx = max(mx, querymax(i << 1, l, mid, x, y));
if (y > mid) mx = max(mx, querymax(i << 1 | 1, mid + 1, r, x, y));
return mx;
}

IT spilit (int pos) {
IT it = s.lower_bound(node(pos));
if(it != s.end() && it->l == pos) return it;
it--;
int L = it -> l, R = it -> r;
int V = it->v;
s.erase(it);
s.insert(node(L, pos-1, V));
return s.insert(node(pos, R, V)).first;
}

void assign(int l, int r, int val = 0) {
IT ir = spilit(r+1), il = spilit(l);
s.erase(il, ir);
s.insert(node(l, r, val));
}

int query1(int l, int r) {
int ans = 2147483647, lef; memset(ap, 0, sizeof ap);
IT ir = spilit(r+1), il = spilit(l), L, R; --il;
L = R = il; lef = m;
while(R != ir) {
if(L != il) {--ap[L->v]; if(!ap[L->v]) ++lef;} ++L;
while(lef && R != ir) {++R; ++ap[R->v]; if(ap[R->v] == 1) --lef;}
if(R == ir) break;
while(!lef && L != R) {--ap[L->v]; if(!ap[L->v]) ++lef; ++L;}
if(lef) {--L; ++ap[L->v]; --lef;}
ans = min(ask(L->r, R->l), ans);
}
return ans;
}

int query2(int l, int r) {
memset(apt, 0, sizeof apt);
int ans = querymax(1, 1, n, l, r);
IT ir = spilit(r+1), il = spilit(l), R, L;
R = il; --il; L = il;
while(R != ir) {
if(L != il) apt[L->v] = 0; ++L;
apt[L->v] = 1;
while(R->l < L->r) ++R;
if(L == R) ++R;
if(R == ir) break;
while(!apt[R->v] && R != ir && R->l == R->r) {apt[R->v] = 1; ++R;}
if(R == ir) --R;
else if(!apt[R->v]) apt[R->v] = 1; else --R;
if(L == R) continue;
//cout << L->r << " " << R->l << endl;
ans = max(ans, ask(L->r, R->l));
}
return ans;
}

int main() {
s.insert(node(0, 0, -1)); s.insert((n+1, n+1, -1));
for(int x, i = 1; i <= n; ++i) read(x), update(i, x), updatemax(1, 1, n, i, x);
for(int x, i = 1; i <= n; ++i) read(x), s.insert(node(i, i, x));
int opt, l, r, x;
while(q--) {
if(opt == 1) {
update(l, r - ask(l, l));
updatemax(1, 1, n, l, r);
} else if(opt == 2) {
}