2017年11月01日普及组 I Will Like Matrix!

来源:互联网 发布:手机系统升级软件 编辑:程序博客网 时间:2024/05/20 14:44

Description

在一个 n ∗ m 的矩阵 A 的所有位置中分别填入 0 或 1,要求填入的数必须满足 Ai,j ≤ Ai,j+1 且
A i,j ≤ A i+1,j 。询问一共有多少种不同的矩阵,并将答案对 1,000,000,007 取模。

Input

共一行包含两个整数 n 和 m。

Output

共一行包含一个整数 ans,表示矩阵个数模 1,000,000,007 的值。

Sample Input

2 2
Sample Output

6
Hint

对于 60% 的数据:n,m,k ≤ 300
对于 100% 的数据:n,m,k ≤ 5000

程序:

constp:longint=1000000007;varn,m,i,j,t:longint;f:array[0..5000,0..5000]of longint;begin    assign(input,'future.in');    reset(input);    assign(output,'future.out');    rewrite(output);    read(n,m);    for i:=0 to n do    for j:=0 to m do    if i*j=0 then f[i,j]:=1 else f[i,j]:=(f[i,j-1]+f[i-1,j]) mod p;    writeln(f[n,m]);    close(input);    close(output);end.
原创粉丝点击