A9102 | Vasily the Bear and Beautiful Strings
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasily the Bear loves beautiful strings. String $s$ is beautiful if it meets the following criteria:
1. String $s$ only consists of characters $0$ and $1$ , at that character $0$ must occur in string $s$ exactly $n$ times, and character $1$ must occur exactly $m$ times.
2. We can obtain character $g$ from string $s$ with some (possibly, zero) number of modifications. The character $g$ equals either zero or one.
A modification of string with length at least two is the following operation: we replace two last characters from the string by exactly one other character. This character equals one if it replaces two zeros, otherwise it equals zero. For example, one modification transforms string "01010" into string "0100", two modifications transform it to "011". It is forbidden to modify a string with length less than two.
Help the Bear, count the number of beautiful strings. As the number of beautiful strings can be rather large, print the remainder after dividing the number by $1000000007$ $(10^{9}+7)$ .
1. String $s$ only consists of characters $0$ and $1$ , at that character $0$ must occur in string $s$ exactly $n$ times, and character $1$ must occur exactly $m$ times.
2. We can obtain character $g$ from string $s$ with some (possibly, zero) number of modifications. The character $g$ equals either zero or one.
A modification of string with length at least two is the following operation: we replace two last characters from the string by exactly one other character. This character equals one if it replaces two zeros, otherwise it equals zero. For example, one modification transforms string "01010" into string "0100", two modifications transform it to "011". It is forbidden to modify a string with length less than two.
Help the Bear, count the number of beautiful strings. As the number of beautiful strings can be rather large, print the remainder after dividing the number by $1000000007$ $(10^{9}+7)$ .
输入格式
The first line of the input contains three space-separated integers $n,m,g$ $(0<=n,m<=10^{5},n+m>=1,0<=g<=1)$ .
输出格式
Print a single integer — the answer to the problem modulo $1000000007$ $(10^{9}+7)$ .
输入输出样例
输入 #1
1 1 0
输出 #1
2
输入 #2
2 2 0
输出 #2
4
输入 #3
1 1 1
输出 #3
0
In the first sample the beautiful strings are: "01", "10".
In the second sample the beautiful strings are: "0011", "1001", "1010", "1100".
In the third sample there are no beautiful strings.
In the second sample the beautiful strings are: "0011", "1001", "1010", "1100".
In the third sample there are no beautiful strings.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted