A9179 | Valera and Fools
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
One fine morning, $n$ fools lined up in a row. After that, they numbered each other with numbers from $1$ to $n$ , inclusive. Each fool got a unique number. The fools decided not to change their numbers before the end of the fun.
Every fool has exactly $k$ bullets and a pistol. In addition, the fool number $i$ has probability of $p_{i}$ (in percent) that he kills the fool he shoots at.
The fools decided to have several rounds of the fun. Each round of the fun looks like this: each currently living fool shoots at another living fool with the smallest number (a fool is not stupid enough to shoot at himself). All shots of the round are perfomed at one time (simultaneously). If there is exactly one living fool, he does not shoot.
Let's define a situation as the set of numbers of all the living fools at the some time. We say that a situation is possible if for some integer number $j$ ( $0<=j<=k$ ) there is a nonzero probability that after $j$ rounds of the fun this situation will occur.
Valera knows numbers $p_{1},p_{2},...,p_{n}$ and $k$ . Help Valera determine the number of distinct possible situations.
Every fool has exactly $k$ bullets and a pistol. In addition, the fool number $i$ has probability of $p_{i}$ (in percent) that he kills the fool he shoots at.
The fools decided to have several rounds of the fun. Each round of the fun looks like this: each currently living fool shoots at another living fool with the smallest number (a fool is not stupid enough to shoot at himself). All shots of the round are perfomed at one time (simultaneously). If there is exactly one living fool, he does not shoot.
Let's define a situation as the set of numbers of all the living fools at the some time. We say that a situation is possible if for some integer number $j$ ( $0<=j<=k$ ) there is a nonzero probability that after $j$ rounds of the fun this situation will occur.
Valera knows numbers $p_{1},p_{2},...,p_{n}$ and $k$ . Help Valera determine the number of distinct possible situations.
输入格式
The first line contains two integers $n,k$ ( $1<=n,k<=3000$ ) — the initial number of fools and the number of bullets for each fool.
The second line contains $n$ integers $p_{1},p_{2},...,p_{n}$ ( $0<=p_{i}<=100$ ) — the given probabilities (in percent).
The second line contains $n$ integers $p_{1},p_{2},...,p_{n}$ ( $0<=p_{i}<=100$ ) — the given probabilities (in percent).
输出格式
Print a single number — the answer to the problem.
输入输出样例
输入 #1
3 3 50 50 50
输出 #1
7
输入 #2
1 1 100
输出 #2
1
输入 #3
2 1 100 100
输出 #3
2
输入 #4
3 3 0 0 0
输出 #4
1
In the first sample, any situation is possible, except for situation ${1,2}$ .
In the second sample there is exactly one fool, so he does not make shots.
In the third sample the possible situations are ${1,2}$ (after zero rounds) and the "empty" situation ${}$ (after one round).
In the fourth sample, the only possible situation is ${1,2,3}$ .
In the second sample there is exactly one fool, so he does not make shots.
In the third sample the possible situations are ${1,2}$ (after zero rounds) and the "empty" situation ${}$ (after one round).
In the fourth sample, the only possible situation is ${1,2,3}$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted