CF894B.Ralph And His Magic Field

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to k, where k is either 1 or -1.

Now Ralph wants you to figure out the number of ways to put numbers in each block in such a way that the magic field works properly. Two ways are considered different if and only if there exists at least one block where the numbers in the first way and in the second way are different. You are asked to output the answer modulo 1000000007 = 109 + 7.

Note that there is no range of the numbers to put in the blocks, but we can prove that the answer is not infinity.

拉尔夫有一块魔法田地,被划分为 n×mn \times m 个方格,即该田地共有 nn 行和 mm 列。拉尔夫可以在每个方格中填入一个整数。然而,这块魔法田地并非总能正常工作;它仅在每行中所有整数的乘积以及每列中所有整数的乘积均等于 kk 时才正常工作,其中 kk 为 11 或 −1-1。

现在拉尔夫希望你计算出:有多少种方法在每个方格中填入整数,使得该魔法田地能够正常工作?若两种填法在至少一个方格中所填数字不同,则认为它们是不同的方案。你需要输出答案对 1000000007=109+71000000007 = 10^9 + 7 取模的结果。

注意:对填入方格的整数没有取值范围限制,但我们可证明答案是有限的(即不是无穷大)。

输入格式

The only line contains three integers n, m and k (1 ≤ n, m ≤ 1018, k is either 1 or -1).

唯一一行包含三个整数 nn、mm 和 kk(1 ≤ n, m ≤ 10181 ≤ n, m ≤ 10^{18},kk 为 11 或 −1-1)。

输出格式

Print a single number denoting the answer modulo 1000000007.

输出一个整数,表示答案对 1000000007 取模的结果。

输入输出样例

  • 输入#1

    1 1 -1

    输出#1

    1
  • 输入#2

    1 3 1

    输出#2

    1
  • 输入#3

    3 3 -1

    输出#3

    16

说明/提示

In the first example the only way is to put -1 into the only block.

In the second example the only way is to put 1 into every block.

在第一个例子中,唯一的方法是将 −1-1 放入唯一的块中。

在第二个例子中,唯一的方法是将 11 放入每个块中。

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

首页