HDU 5673 Robot

26 篇文章 0 订阅

Robot

Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 611    Accepted Submission(s): 313


Problem Description
There is a robot on the origin point of an axis.Every second, the robot can move right one unit length or do nothing.If the robot is 
on the right of origin point,it can also move left one unit length.A route is a series of movement. How many different routes there are
that after  n  seconds the robot is still located on the origin point?
The answer may be large. Please output the answer modulo  1,000,000,007
 

Input
There are multiple test cases. The first line of input contains an integer  T(1T100)  indicating the number of test cases. For each test case:

The only line contains one integer  n(1n1,000,000) .
 

Output
For each test case, output one integer.
 

Sample Input
  
  
3 1 2 4
 

Sample Output
  
  
1 2 9
 

Source
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:  6229 6228 6227 6226 6225 

题意:在x轴上,机器人从原点出发,如果它在原点,他只可以向右走一格,或者停留原处(表明机器人不可以到负数坐标的位置);
如果不在原点,它可以向右,向左,停留原地;每次操作花费1秒;问n秒后,机器人回到原点的行走方法数;
思路:
过程中一定是向右走的步数>=向左走的步数,最后是相等。想到了什么?括号匹配? 求方法数->卡特兰数。
现在还有一个是停在原地。设停在原地为y次。向右走为x次,那么向左走也为x次。
2*x+y==n;
那么确定了x,y。方法数:C(n,y)*h(x). 很显然;



#include
     
     
      
      
#include
      
      
       
       
#include
       
       
        
        
#include
        
        
         
         
#define N 1000005
#define Mod 1000000007
using namespace std;
typedef long long LL;
LL C[N],Cat[N],inv[N];

void Pre(){
    inv[1] = 1;
    for(int i=2; i
         
         
        
        
       
       
      
      
     
     


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七情六欲·

学生党不容易~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值