CF336D.Vasily the Bear and Beautiful Strings

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 (109 + 7).

瓦西里熊喜欢优美的字符串。字符串 ss 是优美的,当且仅当它满足以下条件:

  1. 字符串 ss 仅由字符 0 和 1 构成,其中字符 0 在 ss 中恰好出现 nn 次,字符 1 恰好出现 mm 次。
  2. 我们可以通过对字符串 ss 进行若干次(可能为零次)修改操作,得到单个字符 gg。字符 gg 的取值为 0 或 1。

对长度至少为 22 的字符串进行一次修改操作的定义如下:将字符串末尾的两个字符替换为恰好一个其他字符。该新字符为 1 当且仅当被替换的两个字符均为 0;否则该新字符为 0。例如,一次修改将字符串 "01010" 变为 "0100",两次修改可将其变为 "011"。不允许对长度小于 22 的字符串执行修改操作。

请帮助熊计算优美的字符串的个数。由于优美字符串的个数可能非常大,请输出该数目对 10000000071000000007(即 109+710^9 + 7)取模的结果。

输入格式

The first line of the input contains three space-separated integers n, m, g (0 ≤ n, m ≤ 105, n + m ≥ 1, 0 ≤ g ≤ 1).

输入的第一行包含三个以空格分隔的整数 nn、mm、gg(0 ≤ n, m ≤ 1050 \le n, m \le 10^5,n + m ≥ 1n + m \ge 1,0 ≤ g ≤ 10 \le g \le 1)。

输出格式

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

输出一个整数——该问题答案对 10000000071000000007(即 109+710^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.

在第一个样例中,优美的字符串有:“01”、“10”。

在第二个样例中,优美的字符串有:“0011”、“1001”、“1010”、“1100”。

在第三个样例中,不存在优美的字符串。

输入解题思路,AI测评打分。不知道怎么写?

首页