Codeforces Round #284
来源:互联网 发布:能查高数题的软件 编辑:程序博客网 时间:2024/04/28 00:56
来做场模拟赛调整心情,结果发现题目好水……
A:平面上有n条直线 aix + biy + ci = 0, 给出学校所标和家的坐标,问从家到学校至少跨过几条直线。
想到若两点再一条直线两侧,这条直线被经过。
B:有n首歌曲按顺序播放,第i首歌有pi, ti,pi代表这首歌每听一秒能认出它的概率,ti为在ti秒这一刻你一定能听出来了。只有在认出来后才会播放下一首,总时限为T,问期望能播几首歌。N, T <= 5000。
O(n^3)的dp易想到,f[i][j]表示过了i秒现在在听j的概率。ans在转移时顺便处理。优化用类似前缀和,或在转移时减去ti秒前的即可。
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <string>#define Rep(i, x, y) for (int i = x; i <= y; i ++)#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)using namespace std;typedef long long LL;const int N = 5005;int n, T, t[N];double f[2][N], g[2][N], ans, p[N];int main(){scanf ("%d%d", &n, &T);Rep(i, 1, n) {scanf ("%lf%d", &p[i], &t[i]);p[i] /= 100;}f[1][1] = 1;Rep(i, 1, n) {double u = 1;int o = (i & 1);memset(f[o^1], 0, sizeof(f[o^1]));Rep(j, 1, t[i] - 1) u *= (1 - p[i]);Rep(j, 1, T) {g[o][j] = f[o][j];f[o][j] += f[o][j-1] * (1 - p[i]);if (j >= t[i]) f[o][j] -= g[o][j - t[i] + 1] * u;}Rep(j, 1, T) {f[o^1][j+1] += f[o][j] * p[i];if (j > t[i]) f[o^1][j] += g[o][j - t[i]] * u;}Rep(j, 1, T) {if (t[i] > 1) ans += f[o][j] * p[i];if (j + t[i] - 1 <= T) ans += g[o][j] * u;}}printf ("%.8f\n", ans); return 0;}
C:有n个数,一次操作将两个数(有m对可选)同时除以v,问能做多少次操作。n, m <= 100.
标答是二分图,我的是网络流……
首先易想到对于每个素数是独立的。枚举素数,然后建图也不难。
总之,刷cf是调整状态,找信心的好方法。
0 0
- Codeforces Round #284 (Div2)
- Codeforces Round #284
- 【codeforces】Codeforces Round #284 (Div. 1) 【题解】
- Codeforces Round #284 (Div. 1)
- Codeforces Round #284 (Div. 2)
- Codeforces Round #284 (Div. 2)
- 【codeforces】Codeforces Round #363
- codeforces 283,284(Round #174)题解
- Codeforces Round #284 (Div. 1) A
- Codeforces Round #284 (Div. 2) C
- Codeforces Round #284 (Div. 2)B. Lecture
- Codeforces Round #284 (Div. 1) C
- Codeforces Round #284 (Div. 1) B
- A && B Codeforces Round #284 (Div. 2)
- Codeforces Round #270 Codeforces Round #270
- 【Codeforces】Codeforces Round #271 div2
- 【CODEFORCES】 Educational Codeforces Round 1
- Codeforces Educational Codeforces Round 5
- Mahout学习资料
- poj解题报告——1276
- POJ算法做题顺序[转]
- 链式CIK治疗技术简介
- Comparison of Android versions(2014上海全国邀请赛)
- Codeforces Round #284
- [UvaOJ]494-Kindergarten Counting Game
- gradle学习(2)-基础语法
- JSONObject对象的optXXX和getXXX的区别
- Linux块设备加密之dm-crypt分析
- java异常机制详解
- uva 10604(dp + 回溯)
- DICOM医学图像处理:DICOM存储操作之 “多幅JPG图像数据存入DCM文件”
- POJ3278 抓奶牛 BFS