CF1575K.Knitting Batik
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mr. Chanek wants to knit a batik, a traditional cloth from Indonesia. The cloth forms a grid a with size n×m . There are k colors, and each cell in the grid can be one of the k colors.
Define a sub-rectangle as an ordered pair of two cells ((x1,y1),(x2,y2)) , denoting the top-left cell and bottom-right cell (inclusively) of a sub-rectangle in a . Two sub-rectangles ((x1,y1),(x2,y2)) and ((x3,y3),(x4,y4)) have the same pattern if and only if the following holds:
- they have the same width ( x2−x1=x4−x3 );
- they have the same height ( y2−y1=y4−y3 );
- for every pair (i,j) where 0≤i≤x2−x1 and 0≤j≤y2−y1 , the color of cells (x1+i,y1+j) and (x3+i,y3+j) are equal.
Count the number of possible batik color combinations, such that the subrectangles ((ax,ay),(ax+r−1,ay+c−1)) and ((bx,by),(bx+r−1,by+c−1)) have the same pattern.
Output the answer modulo 109+7 .
输入格式
The first line contains five integers n , m , k , r , and c ( 1≤n,m≤109 , 1≤k≤109 , 1≤r≤min(106,n) , 1≤c≤min(106,m) ) — the size of the batik, the number of colors, and size of the sub-rectangle.
The second line contains four integers ax , ay , bx , and by ( 1≤ax,bx≤n , 1≤ay,by≤m ) — the top-left corners of the first and second sub-rectangle. Both of the sub-rectangles given are inside the grid ( 1≤ax+r−1 , bx+r−1≤n , 1≤ay+c−1 , by+c−1≤m ).
输出格式
Output an integer denoting the number of possible batik color combinations modulo 109+7 .
输入输出样例
输入#1
3 3 2 2 2 1 1 2 2
输出#1
32
输入#2
4 5 170845 2 2 1 4 3 1
输出#2
756680455
说明/提示
The following are all 32 possible color combinations in the first example.