1246-colorful Board

Source: Internet
Author: User

1246-colorful Board
PDF (中文版) Statistics Forum
Time Limit:2 second (s) Memory limit:32 MB

You are given a rectangular board. You is asked to draw M horizontal lines and N vertical lines on that board, so, the whole board wil L is divided into (m+1) x (n+1) cells. So, there'll is m+1 rows Each of which would exactly contain n+1 cells or columns. The yth cell of xth row can be called as cell (x, y). The distance between is the summation of row difference and column difference of those. So, the distance between cell (x1, y1) and cells (x2, y2) is

|x1-x2| + |y1-y2|

For example, the distance between cell (2, 3) and cells (3, 2) is |2-3| + |3-2| = 1 + 1 = 2.

After so you have a to color every cell of the board. For that is given K different colors. The board more beautiful you has to make sure that no, the cells have the same color can has odd distance betwe En them. For example, if you color cells (3, 5) with red, you cannot color cells (5, 8) with red, as the distance between them are 5, which is odd. Note that you can keep some color unused, and you can ' t keep some cell uncolored.

Determine how many ways to color the board using those K colors.

Input

Input starts with an integer T (≤20000), denoting the number of test cases.

Each case starts with a line containing three integers M, N, K (0≤m, n≤19, 1≤k≤50).

Output

For each case, print the case number and the number of ways you can color the board. The result can be large, so print the result modulo 1000000007.

Sample Input Output for Sample Input

4

0 0 1

0 0 2

5 5 2

5 5 1

Case 1:1

Case 2:2

Case 3:2

Case 4:0

Problem SETTER:MD. Arifuzzaman arifspecial thanks:jane ALAM jan1246-colorful Board
PDF (中文版) Statistics Forum
Time Limit:2 second (s) Memory limit:32 MB

You are given a rectangular board. You is asked to draw M horizontal lines and N vertical lines on that board, so, the whole board wil L is divided into (m+1) x (n+1) cells. So, there'll is m+1 rows Each of which would exactly contain n+1 cells or columns. The yth cell of xth row can be called as cell (x, y). The distance between is the summation of row difference and column difference of those. So, the distance between cell (x1, y1) and cells (x2, y2) is

|x1-x2| + |y1-y2|

For example, the distance between cell (2, 3) and cells (3, 2) is |2-3| + |3-2| = 1 + 1 = 2.

After so you have a to color every cell of the board. For that is given K different colors. The board more beautiful you has to make sure that no, the cells have the same color can has odd distance betwe En them. For example, if you color cells (3, 5) with red, you cannot color cells (5, 8) with red, as the distance between them are 5, which is odd. Note that you can keep some color unused, and you can ' t keep some cell uncolored.

Determine how many ways to color the board using those K colors.

Input

Input starts with an integer T (≤20000), denoting the number of test cases.

Each case starts with a line containing three integers M, N, K (0≤m, n≤19, 1≤k≤50).

Output

For each case, print the case number and the number of ways you can color the board. The result can be large, so print the result modulo 1000000007.

Sample Input Output for Sample Input

4

0 0 1

0 0 2

5 5 2

5 5 1

Case 1:1

Case 2:2

Case 3:2

Case 4:0

Problem SETTER:MD. Arifuzzaman arifspecial Thanks:jane ALAM Jan thought: Lattice can be divided into two categories, like a chess and so we just look at the black chess case, to determine the color of the white lattice, that is, in the black lattice is not filled with the color, if it is X, The number of black lattice is k, then the number of black lattice is xk; then multiply the number of programs in the white grid. So we need to discuss the number of colors in the white lattice, and the number of its species, the number of the white lattice is Y, we ask that when there is a color of the scheme number, then this translates into, the y thing into the I box of the different schemes. Then Strlin (y,i) * (i! );
1#include <stdio.h>2#include <algorithm>3#include <string.h>4#include <iostream>5 using namespacestd;6typedefLong LongLL;7 ConstLL n=1000000007;8LL yan[1005][1005];9LL stl[1005][1005];TenLL pp[1005]; One ll Quick (ll n,ll m); A intMainvoid) - { -         inti,j,k; thescanf"%d",&k); -         ints; -yan[0][0]=1; -          for(i=1; i<= +; i++) +         { -                  for(j=0; j<=i; J + +) +                 { A                         if(j==0|| i==j) atyan[i][j]=1; -                         Else -                         { -Yan[i][j]= (yan[i-1][j]+yan[i-1][j-1])%N; -                         } -                 } in         } -pp[0]=1; to          for(i=1; i<= +; i++) +Pp[i]= (pp[i-1]*i)%N; -memset (STL,0,sizeof(STL)); thestl[0][0]=1; *stl[1][0]=0; $stl[1][1]=1;Panax Notoginseng          for(i=2; i<= +; i++) -         { the                  for(j=1; j<=i; J + +) +                 { A                         if(j==1|| i==j) thestl[i][j]=1; +                         Else -                         { $Stl[i][j]= ((stl[i-1][J]*J)%n+stl[i-1][j-1])%N; $                         } -                 } -         } the          for(s=1; s<=k; s++) -         {Wuyi                 intx1,x2,x3,x4; thescanf" %d%d%d",&x1,&x2,&x3); -x1+=1; Wux2+=1; -LL sum= (x1*x2); AboutLL he= (sum+1)/2; $LL cnt=0; -                  for(i=1; I<=min (LL) x3,he); i++) -                 { -LL x=x3-i; ALL Kk=quick (x,sum-He); +LL ak= ((stl[he][i]*yan[x3][i]%n) *kk)%N; thecnt= (cnt+ak*pp[i]%n)%N; -                 } $printf"Case %d:", s); theprintf"%lld\n", CNT); the         } the         return 0; the } -  in ll Quick (ll n,ll m) the { theLL ans=1; n%=N; About          while(m) the         { the                 if(m&1) theans= (ans*n)%N; +n= (n*n)%N; -M/=2; the         }Bayi         returnans; the}

1246-colorful Board

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.