题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5698

Problem Description

有一个无限大的矩形,初始时你在左上角(即第一行第一列),每次你都可以选择一个右下方格子,并瞬移过去(如从下图中的红色格子能直接瞬移到蓝色格子),求到第nnn行第mmm列的格子有几种方案,答案对100000000710000000071000000007取模。

Input

多组测试数据。

两个整数n,m(2≤n,m≤100000)n,m(2\leq n,m\leq 100000)n,m(2≤n,m≤100000)

Output

一个整数表示答案

Sample Input
4 5
Sample Output
10
 
 
 

/*
#include<stdio.h>
#include<stdlib.h>
int a[300][300]={0};
int main()
{
int n,m,i,j;
//printf("%d\n",a[1][1]);
for (i=2;i<300;i++)
{
a[i][2] = 1;
a[2][i] = 1;
}
for (i=3;i<300;i++)
{
for (j=3;j<300;j++)
{
a[i][j] = a[i][j-1]+a[i-1][j];
a[i][j] = a[i][j]%1000000007;
}
}
while (scanf("%d%d",&n,&m)!=EOF)
{
printf("%d\n",a[n][m]);
}
return 0;
}
*/ //ac代码
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#define ll __int64
#define mod 1000000007
using namespace std;
ll poww(ll a,ll n)
{
ll r=,p=a;
while(n)
{
if(n&) r=(r*p)%mod;
n>>=;
p=(p*p)%mod;
}
return r;
}
ll coun(ll n,ll m)
{
ll sum=;
for(ll i=,j=n;i<=m;i++,j--)
{
sum*=j;
sum%=mod;
sum*=poww(i,);
sum%=mod;
}
return sum;
}
ll x,y,z,t;
ll n,k;
ll ans;
int main()
{
while(scanf("%I64d %I64d",&x,&y)!=EOF)
{
ans=;
n=(x+y)-;
k=x-;
ans=coun(n,k);
cout<<ans<<endl;
}
return ;
} /*
//ac代码
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define mod 1000000007
#define inf 999999999
#define pi 4*atan(1)
//#pragma comment(linker, "/STACK:102400000,102400000")
int scan()
{
int res = 0 , ch ;
while( !( ( ch = getchar() ) >= '0' && ch <= '9' ) )
{
if( ch == EOF ) return 1 << 30 ;
}
res = ch - '0' ;
while( ( ch = getchar() ) >= '0' && ch <= '9' )
res = res * 10 + ( ch - '0' ) ;
return res ;
}
void extend_Euclid(ll a, ll b, ll &x, ll &y)
{
if(b == 0)
{
x = 1;
y = 0;
return;
}
extend_Euclid(b, a % b, x, y);
ll tmp = x;
x = y;
y = tmp - (a / b) * y;
}
ll combine1(ll n,ll m) //计算组合数C(n,m)
{
ll sum=1; //线性计算
for(ll i=1,j=n;i<=m;i++,j--)
{
sum*=j;
sum%=mod;
ll x,y;
extend_Euclid(i,mod,x,y);
sum*=(x%mod+mod)%mod;
sum%=mod;
}
return sum;
}
int main()
{
ll x,y,z,i,t;
while(~scanf("%I64d%I64d",&x,&y))
{
ll n,k;
ll ans=0;
k=x-2;
n=(x+y)-4;
ans=combine1(n,k);
printf("%I64d\n",ans);
}
return 0;
} */

杭电acm5698-瞬间移动(2016"百度之星" - 初赛(Astar Round2B))的更多相关文章

  1. 2016"百度之星" - 初赛(Astar Round2B) 1006 中位数计数

    思路:统计当前数左边比它小|大 i个人,相应右边就应该是比它大|小i个人 l数组表示左边i个人的方案 r表示右边i个人的方案 数组下标不可能是负数所以要加n //#pragma comment(lin ...

  2. 2016百度之星-初赛(Astar Round2A)AII X

    Problem Description F(x,m) 代表一个全是由数字x组成的m位数字.请计算,以下式子是否成立: F(x,m) mod k ≡ c Input 第一行一个整数T,表示T组数据. 每 ...

  3. 2016百度之星 初赛2A ABEF

    只做了1001 1002 1005 1006.剩下2题可能以后补? http://acm.hdu.edu.cn/search.php?field=problem&key=2016%22%B0% ...

  4. HDU 5690:2016"百度之星" - 初赛 All X

    原文链接:https://www.dreamwings.cn/hdu5690/2657.html All X Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  5. 2016"百度之星" - 初赛(Astar Round2A)HDU 5695 拓扑排序+优先队列

    Gym Class Time Limit: 6000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total S ...

  6. 2016"百度之星" - 初赛(Astar Round2B)1003 瞬间移动 组合数学+逆元

    瞬间移动  Accepts: 1018  Submissions: 3620  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: 65536/ ...

  7. 2016百度之星 初赛2B ACEF

    做了1001 1003 1005 1006 看题:http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=702 交题:http://acm ...

  8. 2016"百度之星" - 初赛(Astar Round2B)

    Problem Description 中位数定义为所有值从小到大排序后排在正中间的那个数,如果值有偶数个,通常取最中间的两个数值的平均数作为中位数. 现在有n个数,每个数都是独一无二的,求出每个数在 ...

  9. 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)

    Gym Class  Accepts: 849  Submissions: 4247  Time Limit: 6000/1000 MS (Java/Others)  Memory Limit: 65 ...

随机推荐

  1. msp430入门编程27

    msp430中C语言开发工具调试程序 msp430入门学习 msp430入门编程

  2. Flex4分模块下样式动态加载步骤及相关问题的解决

    1.  给应用程序编写CSS文件 (1)在项目下创建CSS文件(任意路径,可以多个).本例在src下创建了5个样式文件 (2)Flex支持的CSS文件定义如下: a)  type selector(类 ...

  3. poj——3177Redundant Paths

    poj——3177Redundant Paths      洛谷—— P2860 [USACO06JAN]冗余路径Redundant Paths Time Limit: 1000MS   Memory ...

  4. Spring的@Qualifier注解

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/annotation-based-configuration/spring-qualifier-an ...

  5. xml文件的schema也是经过jdk编译器编译的,如果xsd没引入完整,而xml中又用到了这些标签,就会编译不通过啊。

    1.xml文件的schema也是经过jdk编译器编译的,如果xsd没引入完整,而xml中又用到了这些标签,就会编译不通过啊. 2.java编译器会下载xsd的指定链接文件,加在代码里,一起编译

  6. vs2015编译zlib1.2.8

    编译最新的libcurl 7.44.0时须要先编译下zlib 1.2.8遇到了点小麻烦 记录下 1.编译步骤 a.先用vs2015命令行运行下bld_ml32.bat批处理 b.将inffas32.o ...

  7. 【转】ubuntu 下安装mongodb php 拓展的方法

    按照上面的方法安装成功之后,写一个 mongodb 的php测试脚本,用来测试是否可以 正确连接上mongodb ,并查询结果. 参考:http://php.net/manual/en/class.m ...

  8. elasticsarch5.4集群安装

    越来越多的企业已经采用ELK解决方案来对其公司产生的日志进行分析,笔者最近着手在生产环境部署自己的ELK stack,本文介绍ELK中elasticsearch5.2集群的实现. 一.环境准备 1.系 ...

  9. Duplicate property mapping of contactPhone found in

    启动的时候报Duplicate property mapping of contactPhone found in com....的错误,是因为在建立实体对象的时候,有字段重复了,有的是继承了父类的字 ...

  10. 编译iOS使用的.a库文件

    首先是须要编译成.a的源文件 hello.h: #ifndef __INCLUDE_HELLO_H__ #define __INCLUDE_HELLO_H__ void hello(const cha ...