Codeforces 128 C. Games with Rectangle
C. Games with Rectangle
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the last-painted rectangle a new lesser rectangle (along the grid lines). The new rectangle should have no common points with the previous one. Note that when we paint a rectangle, we always paint only the border, the rectangles aren't filled.
Nobody wins the game — Anna and Maria simply play until they have done k moves in total. Count the number of different ways to play this game.
Input
The first and only line contains three integers: n, m, k (1 ≤ n, m, k ≤ 1000).
Output
Print the single number — the number of the ways to play the game. As this number can be very big, print the value modulo 1000000007(109 + 7).
Sample test(s)
input
3 3 1
output
1
input
4 4 1
output
9
input
6 7 2
output
75
Note
Two ways to play the game are considered different if the final pictures are different. In other words, if one way contains a rectangle that is not contained in the other way.
In the first sample Anna, who performs her first and only move, has only one possible action plan — insert a 1 × 1 square inside the given3 × 3 square.
In the second sample Anna has as much as 9 variants: 4 ways to paint a 1 × 1 square, 2 ways to insert a 1 × 2 rectangle vertically, 2 more ways to insert it horizontally and one more way is to insert a 2 × 2 square.
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long int LL;
const LL MOD=1000000007LL;
LL n,m,k;
LL C[1200][1200];
void init()
{
for(int i=0;i<1200;i++)
C[i][i]=C[i][0]=1LL;
for(int i=2;i<1200;i++)
{
for(int j=1;j<i;j++)
{
C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
}
}
}
int main()
{
init();
cin>>n>>m>>k;
if(n-1<2*k||m-1<2*k)
cout<<0<<endl;
else
cout<<(C[n-1][2*k]*C[m-1][2*k])%MOD<<endl;
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.