• [Luogu 2265]路边的水沟


    Description

    LYQ市有一个巨大的水沟网络,可以近似看成一个n*m的矩形网格,网格的每个格点都安装了闸门,我们将从水沟网络右下角的闸门到左上角的闸门的一条路径称为水流。

    现给定水沟网的长和宽,求该水沟网中所有只包含向左和向上移动的水流数量。

    Input

    输入共1行,包含两个整数n和m。

    Output

    输出一个数字ans,即水流的数量。由于答案可能很大,请输出答案对1000000007取模的结果。

    Sample Input

    3 5

    Sample Output

    56

    Hint

    对于30%的数据,1 ≤ m,n ≤ 10。

    对于50%的数据,1 ≤ m,n ≤ 1,000。

    对于80%的数据,1 ≤ m,n ≤ 50,000。

    对于100%的数据,1 ≤ m,n ≤ 1,000,000。

    题解

    乘法逆元模板...

     1 //It is made by Awson on 2017.11.2
     2 #include <map>
     3 #include <set>
     4 #include <cmath>
     5 #include <ctime>
     6 #include <queue>
     7 #include <stack>
     8 #include <cstdio>
     9 #include <string>
    10 #include <vector>
    11 #include <cstdlib>
    12 #include <cstring>
    13 #include <iostream>
    14 #include <algorithm>
    15 #define LL long long
    16 #define Max(a, b) ((a) > (b) ? (a) : (b))
    17 #define Min(a, b) ((a) < (b) ? (a) : (b))
    18 #define Abs(a) ((a) < 0 ? (-(a)) : (a))
    19 using namespace std;
    20 const int N = 1000000;
    21 const int MOD = 1000000007;
    22 
    23 int n, m;
    24 int A[(N<<1)+5];
    25 
    26 void work() {
    27     scanf("%d%d", &n, &m);
    28     int ans = 1; A[1] = 1;
    29     for (int i = 2; i <= m; i++) A[i] = -(LL)(MOD/i)*A[MOD%i]%MOD;
    30     for (int i = n+1; i <= m+n; i++) ans = (LL)ans*i%MOD;
    31     for (int i = 2; i <= m; i++) ans = (LL)ans*A[i]%MOD;
    32     printf("%d
    ", (ans+MOD)%MOD);
    33 }
    34 int main() {
    35     work();
    36     return 0;
    37 }
  • 相关阅读:
    网页Tab控件
    ivy在eclipse中的重新加载
    es删除文档或者删除索引
    es修改数据
    es中插入数据
    创建es索引-格式化和非格式化
    MySQL常用字符串函数
    python各种类型转换
    python 3.4读取输入参数
    python异常捕获异常堆栈输出
  • 原文地址:https://www.cnblogs.com/NaVi-Awson/p/7772950.html
Copyright © 2020-2023  润新知