SDOI 2017 Round1 题解
来源:互联网 发布:林弯弯淘宝店铺名 编辑:程序博客网 时间:2024/06/07 12:02
Day1
Problem 1:数字表格
题目描述
Doris刚刚学习了fibonacci数列。用
Doris的表格中共有
答案对
输入格式
有多组测试数据。
第一个一个数
接下来
输出格式
输出
样例1
input
3
2 3
4 5
6 7
output
1
6
960
限制与约定
对
对
另外存在
对
时间限制:5s
内存限制:128M
题解
所以总的复杂度为:
代码
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 1000010, p = 1e9+7;ll fib[maxn], Nfib[maxn], F[maxn], NF[maxn];int prime[maxn], mu[maxn], pcnt, T, n, m, MX;bool is[maxn];ll pow(ll x, ll y){ ll res = 1; for( ; y; y >>= 1, x = (x*x) % p) if(y & 1) res = (res * x) % p; return res;}void pre(){ is[1] = mu[1] = fib[1] = NF[0] = 1; for(int i = 2; i <= MX; i ++){ if(!is[i]) mu[i] = -1, prime[++ pcnt] = i; for(int j = 1; i * prime[j] <= MX; j ++){ is[i * prime[j]] = 1; if(i % prime[j] == 0) break; else mu[i*prime[j]] = - mu[i]; } } for(int i = 2; i <= MX; i ++) fib[i] = (fib[i-1] + fib[i-2]) % p; for(int i = 1; i <= MX; i ++) Nfib[i] = pow(fib[i], p-2); for(int i = 1; i <= MX; i ++) F[i] = 1; for(int i = 1; i <= MX; i ++) for(int j = 1; i*j <= MX; j ++) if(mu[j]) F[i*j] = F[i*j] * (mu[j] == 1 ? fib[i] : Nfib[i]) % p; for(int i = 2; i <= MX; i ++) F[i] = (F[i] * F[i-1]) % p; for(int i = 1; i <= MX; i ++) NF[i] = pow(F[i], p-2); return;}int main(){ MX = 1000000; pre(); scanf("%d", &T); while(T --){ scanf("%d%d", &n, &m); if(n > m) swap(n, m); int last; ll ans = 1; for(int i = 1; i <= n; i = last+1){ last = min(n/(n/i), m/(m/i)); ans = (ans * pow(((F[last] * NF[i-1]) % p + p) % p, 1LL * (n/i) * (m/i) % (p-1))) % p; } printf("%lld\n", ans); } return 0;}
Problem 2:树点涂色
题目描述
Bob有一棵
定义一条路径的权值是:这条路径上的点(包括起点和终点)共有多少种不同的颜色。
Bob可能会进行这几种操作:
1 x
把点
2 x y
求
3 x
在以
Bob一共会进行
输入格式
第一行两个数
接下来
接下来
输出格式
每当出现2,3操作,输出一行。
如果是2操作,输出一个数表示路径的权值
如果是3操作,输出一个数表示权值的最大值
样例1
input
5 6
1 2
2 3
3 4
3 5
2 4 5
3 3
1 4
2 4 5
1 5
2 4 5
output
3
4
2
2
限制与约定
共10个测试点
测试点1,
测试点2、3,没有2操作
测试点4、5,没有3操作
测试点6,树的生成方式是,对于
测试点7,
测试点8,
测试点9,10,无特殊限制
对所有数据,
时间限制:1s
空间限制:128MB
题解
先对树进行树链剖分,线段树每个节点维护该点到跟的路径上的权值。
用
一开始整棵树由轻链连接,每一次修改颜色的的操作是把这个点到跟的路径上的所有点变成一种没有出现过的颜色,对应到
第一种操作,我们
第二种操作,所有的操作都可以总结为下面这张图:
- A区域内的颜色在左右计算的时候都会被计算一次,所以计算了两次。
- B区域内的颜色在左右计算的时候都会被计算一次,所以计算了两次。
- C区域内的颜色只被左边计算了一次。
- D区域内的颜色只被右边计算了一次。
因为B区域被减了两次,但实际需要被算入答案一次,所以答案是两个询问点的权值和减去两倍的
第三种操作,就是线段树的区间最大值。
时间复杂度:
代码
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 100010;struct node{ int id; node *pre, *ch[2]; bool is_root(){return pre->ch[0] != this && pre->ch[1] != this;} void set_ch(int wh, node *child); int wh(){return pre->ch[0] == this ? 0 : 1;}}po[maxn], *null;void node::set_ch(int wh, node *child){ ch[wh] = child; if(child != null) child->pre = this;}int n, m, ct;int head[maxn], to[maxn<<1], nxt[maxn<<1], cnt;int dep[maxn], sz[maxn], fa[maxn], pos[maxn], q[maxn], st[maxn];int son[maxn], dfn[maxn], tp[maxn];bool vis[maxn];int tree[maxn*3], lazy[maxn*3];void add(int a, int b){ nxt[++ cnt] = head[a], to[head[a] = cnt] = b;}#define mid ((l+r)>>1)#define lch ((now<<1))#define rch ((now<<1)|1)void build(int now, int l, int r){ if(l == r){ tree[now] = dep[dfn[l]]; return; } build(lch, l, mid); build(rch, mid+1, r); tree[now] = max(tree[lch], tree[rch]);}void pre(){ dep[1] = 1; int l = 1, r = 0; q[++ r] = 1, vis[1] = 1; while(l <= r){ int x = q[l ++]; sz[x] = 1; for(int i = head[x]; i; i = nxt[i]){ int u = to[i]; if(vis[u]) continue; fa[u] = x, dep[u] = dep[x] + 1; q[++ r] = u, vis[u] = 1; } } for(int i = n; i >= 2; i --) sz[fa[q[i]]] += sz[q[i]]; for(int x = 1; x <= n; x ++){ for(int i = head[x]; i; i = nxt[i]){ int u = to[i]; if(u == fa[x]) continue; if(sz[son[x]] < sz[u]) son[x] = u; } } int top = 0; st[++ top] = 1, tp[1] = 1; while(top){ int x = st[top --]; pos[x] = ++ ct, dfn[ct] = x; for(int i = head[x]; i; i = nxt[i]){ int u = to[i]; if(u == son[x] || u == fa[x]) continue; st[++ top] = u, tp[u] = u; } if(son[x]) st[++ top] = son[x], tp[son[x]] = tp[x]; } for(int i = 1; i <= n; i ++){ po[i].ch[0] = po[i].ch[1] = null; po[i].id = i, po[i].pre = &po[fa[i]]; } build(1, 1, n);}void down(int now, int l, int r){ if(!lazy[now]) return; int &z = lazy[now]; tree[lch] += z, tree[rch] += z; lazy[lch] += z, lazy[rch] += z; z = 0;}void modify(int now, int l, int r, int pos1, int pos2, int c){ if(l == pos1 && r == pos2){ lazy[now] += c; tree[now] += c; return; }down(now, l, r); if(pos2 <= mid) modify(lch, l, mid, pos1, pos2, c); else if(pos1 >= mid+1) modify(rch, mid+1, r, pos1, pos2, c); else modify(lch, l, mid, pos1, mid, c), modify(rch, mid+1, r, mid+1, pos2, c); tree[now] = max(tree[lch], tree[rch]);}int que(int now, int l, int r, int pos1, int pos2){ if(l == pos1 && r == pos2) return tree[now]; down(now, l, r); if(pos2 <= mid) return que(lch, l, mid, pos1, pos2); else if(pos1 >= mid+1) return que(rch, mid+1, r, pos1, pos2); else return max(que(lch, l, mid, pos1, mid), que(rch, mid+1, r, mid+1, pos2));}int Lca(int x, int y){ if(x == y) return x; while(tp[x] != tp[y]){ if(dep[tp[x]] < dep[tp[y]]) swap(x, y); x = fa[tp[x]]; } return dep[x] < dep[y] ? x : y;}void rotate(node *now){ node *fa = now->pre, *gra = fa->pre; int wh = now->wh(); if(!fa->is_root()) gra->ch[gra->ch[0] == fa ? 0 : 1] = now; fa->set_ch(wh, now->ch[wh^1]); now->set_ch(wh^1, fa), now->pre = gra;}void splay(node *now){ for( ; !now->is_root(); rotate(now)) if(!now->pre->is_root()) now->wh() == now->pre->wh() ? rotate(now->pre) : rotate(now);}void access(node *x){ for(node *i = null; x != null; i = x, x = x->pre){ splay(x); if(x->ch[1] != i){ if(x->ch[1] != null){ node *le = x->ch[1]; while(le->ch[0] != null) le = le->ch[0]; int ID = le->id; modify(1, 1, n, pos[ID], pos[ID] + sz[ID] - 1, 1); } x->set_ch(1, i); node *le = i; while(le->ch[0] != null) le = le->ch[0]; if(i != null) modify(1, 1, n, pos[le->id], pos[le->id]+sz[le->id] - 1, -1); } }}int main(){ null = po; null->pre = null->ch[0] = null->ch[1] = null; scanf("%d%d", &n, &m); for(int i = 1, x, y; i < n; i ++){ scanf("%d%d", &x, &y); add(x, y), add(y, x); } pre(); for(int i = 1; i <= m; i ++){ int op, x, y; scanf("%d", &op); if(op == 1){ scanf("%d", &x); access(&po[x]); }else if(op == 2){ scanf("%d%d", &x, &y); int lca = Lca(x, y); printf("%d\n", que(1, 1, n, pos[x], pos[x]) + que(1, 1, n, pos[y], pos[y]) - 2 * que(1, 1, n, pos[lca], pos[lca]) + 1); }else{ scanf("%d", &x); printf("%d\n", que(1, 1, n, pos[x], pos[x] + sz[x] - 1)); } } return 0;}
Problem 3:序列计数
题目描述
Alice想要得到一个长度为
Alice还希望,这
Alice想知道,有多少个序列满足她的要求。
输入格式
一行三个数,
输出格式
一行一个数,满足Alice的要求的序列数量,答案对
样例1
input
3 5 3
input
33
约定与限制
对
对
对
对
时间限制:3s
空间限制:128MB
题解
首先问题可以转换为求所有数的答案减去非质数的答案。
设
这样就可以用矩阵快速幂了,转移矩阵的第
这个次数就是说有数中
然后可以线性筛法预处理这个个数,在
时间复杂度:
代码
#include <cstdio>#include <algorithm>#include <cstring>#include <iostream>using namespace std;const int maxn = 20000010;const int mod = 20170408;int prime[maxn], pcnt;bool is[maxn];int nump[110], num[110], L, MX;int n, m, p;void pre(){ is[1] = 1; num[1] = nump[1] = 1; for(int i = 2; i <= MX; i ++){ if(!is[i]) prime[++ pcnt] = i, nump[i%p] ++; for(int j = 1; i * prime[j] <= MX; j ++){ int w = i * prime[j]; is[w] = 1, num[w%p] ++, nump[w%p] ++; if(i % prime[j] == 0) break; } }}struct Matrix{ long long a[101][101]; Matrix(){memset(a, 0, sizeof(a));} void init(){for(int i = 0; i < L; i ++) a[i][i] = 1;} Matrix operator * (const Matrix &t) const{ Matrix res; for(int i = 0; i < L; i ++) for(int j = 0; j < L; j ++) for(int k = 0; k < L; k ++) res.a[i][j] = (res.a[i][j] + a[i][k] * t.a[k][j] % mod) % mod; return res; }}A, B, T1, T2;Matrix pow(Matrix x, int y){ Matrix res; res.init(); for( ; y; y >>= 1, x = x*x) if(y & 1) res = res * x; return res;}int main(){ scanf("%d%d%d", &n, &m, &p), L = p, MX = m; pre(); A.a[0][0] = B.a[0][0] = 1; for(int i = 0; i < L; i ++){ for(int j = 0; j < L; j ++){ T1.a[i][j] = (T1.a[i][j] + nump[((j-i)%p+p)%p]) % mod; T2.a[i][j] = (T2.a[i][j] + num[((j-i)%p+p)%p]) % mod; } } A = A * pow(T1, n); B = B * pow(T2, n); printf("%d", ((A.a[0][0] - B.a[0][0]) % mod + mod) % mod); return 0;}
Day2
Problem 1:新生舞会
题目描述
学校组织了一次新生舞会,Cathy作为经验丰富的老学姐,负责为同学们安排舞伴。
有
Cathy收集了这些同学之间的关系,比如两个人之前认识没计算得出
Cathy还需要考虑两个人一起跳舞是否方便,比如身高体重差别会不会太大,计算得出
当然,还需要考虑很多其他问题。
Cathy想先用一个程序通过
Cathy找到你,希望你帮她写那个程序。
一个方案中有
Cathy希望
输入格式
第一行一个整数
接下来
接下来
输出格式
一行一个数,表示
样例1
input
3
19 17 16
25 24 23
35 36 31
9 5 6
3 4 2
7 8 9
output
5.357143
限制与约定
对于
对于
另外存在
对于
时间限制:1s
内存限制:128M
题解
把所有的分母乘到右边,在减回来,这样可以二分C的取值,判断当前式子的最大值是否大于0,问题转换为验证一个
还要加上有理有据的常数优化才可以通过。
代码
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 410;const int maxm = 40010;const int inf = 2e9+1;int n;int a[maxn][maxn], b[maxn][maxn], CC;int head[maxn], nxt[maxm], to[maxm], flow[maxm], mxflow[maxm];int q[maxm], l, r, epre[maxn], ppre[maxn], S, T, MX, cnt;double dis[maxn], cost[maxm];bool vis[maxn];void add(int a, int b, int c, double d){ nxt[++ cnt] = head[a], to[head[a] = cnt] = b, flow[cnt] = 0, mxflow[cnt] = c, cost[cnt] = d; nxt[++ cnt] = head[b], to[head[b] = cnt] = a, flow[cnt] = 0, mxflow[cnt] = 0, cost[cnt] = -d;}bool spfa(){ for(int i = 0; i <= MX; i ++){ dis[i] = inf; vis[i] = 0; epre[i] = ppre[i] = 0; } l = 1, r = 0, q[++ r] = S, vis[S] = 1, dis[S] = 0; while(l <= r){ int x = q[l ++]; vis[x] = 0; for(int i = head[x]; i; i = nxt[i]){ int u = to[i]; if(mxflow[i] > flow[i] && dis[u] > dis[x] + cost[i]){ dis[u] = dis[x] + cost[i]; epre[u] = i, ppre[u] = x; if(vis[u] == 0) q[++ r] = u, vis[u] = 1; } } } return dis[T] < inf - 2;}bool work(){ double Cost = 0; while(spfa()){ Cost += dis[T]; if(Cost > 0) return 0; for(int i = T; i != S; i = ppre[i]){ int e = epre[i]; flow[e] ++, flow[e^1] --; } } CC = Cost; if(Cost > 0) return 0; return 1;}int main(){ scanf("%d", &n); S = 2*n+1, T = S+1, MX = T+1; for(int i = 1; i <= n; i ++) for(int j = 1; j <= n; j ++) scanf("%d", &a[i][j]); bool ok = 1; for(int i = 1; i <= n; i ++) for(int j = 1; j <= n; j ++){ scanf("%d", &b[i][j]); if(b[i][j] != 1) ok = 0; } if(ok){ cnt = 1; for(int i = 1; i <= n; i ++){ for(int j = 1; j <= n; j ++){ add(i, n+j, 1, -a[i][j]); } } for(int i = 1; i <= n; i ++) add(S, i, 1, 0), add(i+n, T, 1, 0); work(); printf("%.6lf", -1.0 * CC / n); return 0; } double l = 0, r = 10000; while(r - l >= 0.00000001){ double mid = (r+l)/2; cnt = 1; for(int i = 1; i <= MX; i ++) head[i] = 0; for(int i = 1; i <= n; i ++){ for(int j = 1; j <= n; j ++){ add(i, n+j, 1, - a[i][j] + mid * b[i][j]); } } for(int i = 1; i <= n; i ++) add(S, i, 1, 0), add(n+i, T, 1, 0); if(work()) l = mid; else r = mid; }printf("%.6lf", (l+r)/2); return 0;}
Problem 2:硬币游戏
题目描述
周末同学们非常无聊,有人提议,咱们扔硬币玩吧,谁扔的硬币正面次数多谁胜利。
大家纷纷觉得这个游戏非常符合同学们的特色,但只是扔硬币实在是太单调了。
同学们觉得要加强趣味性,所以要找一个同学扔很多很多次硬币,其他同学记录下正反面情况。
用H表示正面朝上,用
但扔到什么时候停止呢?大家提议,选出
很快,
输入格式
第一行两个整数
接下里
输出格式
输出
选手输出与标准输出的绝对误差不超过
样例1
input
3 3
THT
TTH
HTT
output
0.3333333333
0.2500000000
0.4166666667
限制与约定
对于
对于
对于另外
对于
时间限制:1s
空间限制:128MB
题解
代码
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int maxn = 310;int n, m;char cc[maxn][maxn];long double ec[maxn], a[maxn][maxn];int f[maxn];int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= n; i ++) scanf("%s", cc[i] + 1); ec[0] = 1; for(int i = 1; i <= m; i ++) ec[i] = 0.5 * ec[i-1]; for(int i = 1; i <= n; i ++){ int p = 0; for(int j = 2; j <= m; j ++){ while(p && cc[i][j] != cc[i][p+1]) p = f[p]; if(cc[i][j] == cc[i][p+1]) p ++; f[j] = p; } for(int j = 1; j <= n; j ++){ p = 0; for(int k = 1; k <= m; k ++){ while(p && cc[j][k] != cc[i][p+1]) p = f[p]; if(cc[j][k] == cc[i][p+1]) p ++; } for( ; p; p = f[p]) a[i][j] += ec[m - p]; } a[i][n+1] = ec[0]; } for(int i = 1; i <= n; i ++){ for(int j = i+1; j <= n+1; j ++) a[i][j] /= a[i][i]; a[i][i] = 1; for(int j = i+1; j <= n; j ++){ for(int k = i+1; k <= n+1; k ++) a[j][k] -= a[i][k] * a[j][i]; a[j][i] = 0; } } for(int i = n; i >= 1; i --) for(int j = i+1; j <= n; j ++) a[i][n+1] -= a[i][j] * a[j][n+1]; long double sum = 0; for(int i = 1; i <= n; i ++) sum += a[i][n+1]; for(int i = 1; i <= n; i ++) printf("%.10lf\n", (double)((long double)a[i][n+1] / sum)); return 0;}
Problem 3:相关分析
题目描述
Frank对天文学非常感兴趣,他经常用望远镜看星星,同时记录下它们的信息,比如亮度、颜色等等,进而估算出星星的距离,半径等等。
Frank不仅喜欢观测,还喜欢分析观测到的数据。他经常分析两个参数之间(比如亮度和半径)是否存在某种关系。
现在Frank要分析参数
1 L R:
用直线拟合第L组到底R组观测数据。用
如果直线方程是y=ax+b,那么a应当这样计算:
你需要帮助Frank计算
2 L R S T:
Frank发现测量数据第
3 L R S T:
Frank发现第
输入格式
第一行两个数
接下来一行
接下来一行
接下来
输出格式
对于每个
选手输出与标准输出的绝对误差或相对误差不超过
样例1
input
3 5
1 2 3
1 2 3
1 1 3
2 2 3 -3 2
1 1 2
3 1 2 2 1
1 1 3
input
1.0000000000
-1.5000000000
-0.6153846154
约定与限制
对于
对于另外
对于另外
对于
对于所有数据,
对于所有数据,
时间限制:1s
空间限制:128MB
题解
将上面计算
对于一个3操作,可以考虑先进行区间赋值为标号本身,再做2操作。
等差数列的和和平方和都可以
时间复杂度
代码
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn = 100010;int n, m;double x[maxn], y[maxn];long double S[maxn];#define mid ((l+r)>>1)#define lch ((now<<1))#define rch ((now<<1)|1)struct node{ long double xx, yy, x2, xy; long double tgx, tgy; int is; node(long double a = 0, long double b = 0, long double c = 0, long double d = 0){ xx = a, yy = b, x2 = c, xy = d; tgx = 0, tgy = 0; is = 0; } node operator + (const node &t) const{ node res; res.xx = xx + t.xx; res.yy = yy + t.yy; res.x2 = x2 + t.x2; res.xy = xy + t.xy; return res; }}T[maxn*3];void update(int now, int l, int r){ T[now].xx = (T[lch].xx + T[rch].xx); T[now].yy = (T[lch].yy + T[rch].yy); T[now].x2 = (T[lch].x2 + T[rch].x2); T[now].xy = (T[lch].xy + T[rch].xy);}void build(int now, int l, int r){ if(l == r){ T[now] = node(x[l], y[l], x[l]*x[l], x[l]*y[l]); return; } build(lch, l, mid); build(rch, mid+1, r); update(now, l, r);}void down(int now, int l, int r){ if(T[now].is){ T[lch].is = T[rch].is = 1; T[now].is = 0; T[lch].tgx = T[lch].tgy = T[rch].tgx = T[rch].tgy = 0; T[lch].yy = T[lch].xx = 1.0 * (l+mid) * (mid-l+1) / 2; T[lch].xy = T[lch].x2 = S[mid] - S[l-1]; T[rch].yy = T[rch].xx = 1.0 * (mid+1+r) * (r-mid) / 2; T[rch].xy = T[rch].x2 = S[r] - S[mid]; } long double tgx = T[now].tgx, tgy = T[now].tgy; T[lch].x2 += (mid-l+1) * tgx * tgx + 2 * tgx * T[lch].xx; T[rch].x2 += (r-mid) * tgx * tgx + 2 * tgx * T[rch].xx; T[lch].xy += (mid-l+1) * tgx * tgy + T[lch].xx * tgy + T[lch].yy * tgx; T[rch].xy += (r-mid) * tgx * tgy + T[rch].xx * tgy + T[rch].yy * tgx; T[lch].xx += (mid-l+1) * tgx, T[rch].xx += (r-mid) * tgx; T[lch].yy += (mid-l+1) * tgy, T[rch].yy += (r-mid) * tgy; T[lch].tgx += tgx, T[lch].tgy += tgy; T[rch].tgx += tgx, T[rch].tgy += tgy; T[now].tgx = 0, T[now].tgy = 0;}long double cx, cy;void modify(int now, int l, int r, int pos1, int pos2){ if(pos1 == l && pos2 == r){ T[now].tgx += cx, T[now].tgy += cy; T[now].x2 += (r-l+1) * cx * cx + 2 * cx * T[now].xx; T[now].xy += T[now].xx * cy + T[now].yy * cx + (r-l+1) * cx * cy; T[now].xx += (r-l+1) * cx; T[now].yy += (r-l+1) * cy; return; }down(now, l, r); if(pos2 <= mid) modify(lch, l, mid, pos1, pos2); else if(pos1 >= mid+1) modify(rch, mid+1, r, pos1, pos2); else{ modify(lch, l, mid, pos1, mid); modify(rch, mid+1, r, mid+1, pos2); } update(now, l, r);}node que(int now, int l, int r, int pos1, int pos2){ if(pos1 == l && pos2 == r) return T[now]; down(now, l, r); if(pos2 <= mid) return que(lch, l, mid, pos1, pos2); else if(pos1 >= mid+1) return que(rch, mid+1, r, pos1, pos2); else return que(lch, l, mid, pos1, mid) + que(rch, mid+1, r, mid+1, pos2);}void makeis(int now, int l, int r, int pos1, int pos2){ if(pos1 == l && pos2 == r){ T[now].is = 1; T[now].tgx = T[now].tgy = 0; T[now].yy = T[now].xx = 1.0 * (l+r) * (r-l+1) / 2; T[now].xy = T[now].x2 = S[r] - S[l-1]; return; }down(now, l, r); if(pos2 <= mid) makeis(lch, l, mid, pos1, pos2); else if(pos1 >= mid+1) makeis(rch, mid+1, r, pos1, pos2); else{ makeis(lch, l, mid, pos1, mid); makeis(rch, mid+1, r, mid+1, pos2); } update(now, l, r);}int main(){ scanf("%d%d", &n, &m); for(int i = 1; i <= n; i ++) S[i] = 1.0 * i * i + S[i-1]; for(int i = 1; i <= n; i ++) scanf("%lf", &x[i]); for(int i = 1; i <= n; i ++) scanf("%lf", &y[i]); build(1, 1, n); for(int i = 1; i <= m; i ++){ int op, l, r, s, t; scanf("%d", &op); if(op == 1){ scanf("%d%d", &l, &r); node ans; ans = que(1, 1, n, l, r); long double X = 1.0 * ans.xx / (r-l+1); long double Y = 1.0 * ans.yy / (r-l+1); long double res = ans.xy - ans.yy * X - ans.xx * Y + (r-l+1) * X * Y; res /= (ans.x2 - 2 * ans.xx * X + (r-l+1) * X * X); printf("%.10lf\n", (double)res); }else if(op == 2){ scanf("%d%d%d%d", &l, &r, &s, &t); cx = s, cy = t; modify(1, 1, n, l, r); }else if(op == 3){ scanf("%d%d%d%d", &l, &r, &s, &t); makeis(1, 1, n, l, r); cx = s, cy = t; modify(1, 1, n, l, r); } } return 0;}
- SDOI 2017 Round1 题解
- SDOI 2016 Round1 Bless All
- 【East!模拟赛】【Round1】【codeforces455B】题解。
- Facebook Hacker Cup Round1 2015 题解
- 政史特长生友谊赛Round1题解
- 2017SDOI游记
- SDOI 2017R2游记
- SDOI
- SDOI
- SDOI
- 2016"百度之星" - 资格赛(Astar Round1) 题解
- SDOI 2017 Round 1 滚粗记
- 【BZOJ 4816】【SDOI 2017】数字表格
- 【BZOJ 4818】【SDOI 2017】序列计数
- 【BZOJ 4821】【SDOI 2017】相关分析
- 【BZOJ 4819】【SDOI 2017】新生舞会
- [bzoj4927][SDOI省队集训2017]diyiti
- [bzoj4928][SDOI省队集训2017]dierti
- 管理员操作
- oracle使用hibernate分页时,报找不到ROWNUM_属性解决!
- 如何用搜索引擎获取我需要的信息?
- redis常用命令及redis5大数据类型
- File I\O 使用File类操作文件或目录属性
- SDOI 2017 Round1 题解
- mac版svn客户端利用终端命令的简单使用
- typeAliases别名
- jzoj 5050. 【GDOI2017模拟一试4.11】颜色树 容斥原理
- android 6.0权限管理
- JavaWeb之Session的序列化和反序列化 && Session的活化和钝化
- 【Java学习20170411】反射+Json解析
- Spring Cloud生态系统
- 初到贵地多多关照