从原点到某点,路径不超过对角线。求这样的路径数量。
#include<stdio.h>
#include<iostream>
#define MAX 100
using namespace std;
typedef struct{
long int x;
long int y;
}point;
long long int total[100]={0};
long long int mod=1000000007;
void Recursion(long m,long n,long long int *total)
{
if(m==0&&n==0)
(*total)++;
if((*total)>=mod)
(*total)=(*total)-mod;
if(m>=n)
return;
if(m<0||n<0)
return;
Recursion(m-1,n,total);
Recursion(m,n-1,total);
}
int main()
{
long int m=0,n=0;
int num=0;
scanf("%d",&num);
point record[num];
int numa=0,numb=0,numc=0;
while(numa<num)
{
scanf("%ld %ld",&record[numa].x,&record[numa].y);
numa++;
}
while(numb<num)
{
Recursion(record[numb].x,record[numb].y,&total[numb]);
numb++;
}
while(numc<num)
{
cout<<total[numc]<<endl;
numc++;
}
return 0;
}