hdu 5673 Robot 卡特兰数+逆元
Robot
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
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
The only line contains one integer n(1≤n≤1,000,000).
1
2
4
2
9
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define pi (4*atan(1.0))
- #define eps 1e-14
- const int N=2e5+,M=4e6+,inf=1e9+,mod=1e9+;
- const ll INF=1e18+;
- ll a[M];
- ll inv[M];
- void init()
- {
- inv[] = ;
- for(int i=;i<=;i++)
- {
- if(i >= mod)break;
- inv[i] = (mod - mod / i) * inv[mod % i]% mod;
- }
- }
- ll c[M];
- int main()
- {
- a[]=;
- init();
- for(ll i=;i<=;i++)
- {
- a[i]=(((a[i-]*(*i-))%mod)*inv[i+])%mod;
- }
- int T,cas=;
- scanf("%d",&T);
- while(T--)
- {
- int n;
- scanf("%d",&n);
- c[]=;
- for(int i=,t=n;i<=n;t--,i++)
- {
- c[i]=(((c[i-]*t)%mod)*inv[i])%mod;
- }
- ll ans=;
- for(int i=;i*<=n;i++)
- {
- ans=(ans+(a[i]*c[*i])%mod)%mod;
- }
- printf("%lld\n",ans);
- }
- return ;
- }
hdu 5673 Robot 卡特兰数+逆元的更多相关文章
- hdu 5184 类卡特兰数+逆元
BC # 32 1003 题意:定义了括号的合法排列方式,给出一个排列的前一段,问能组成多少种合法的排列. 这道题和鹏神研究卡特兰数的推导和在这题中的结论式的推导: 首先就是如何理解从题意演变到卡特兰 ...
- hdu 4828 Grids 卡特兰数+逆元
Grids Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Problem D ...
- HDU 5673 Robot【卡特兰数】
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 题意: 有一个机器人位于坐标原点上.每秒钟机器人都可以向右移到一个单位距离,或者在原地不动.如 ...
- HDU 5673 Robot ——(卡特兰数)
先推荐一个关于卡特兰数的博客:http://blog.csdn.net/hackbuteer1/article/details/7450250. 卡特兰数一个应用就是,卡特兰数的第n项表示,现在进栈和 ...
- hdu5673 Robot 卡特兰数+组合数学+线性筛逆元
Robot Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- HDU 4828 (卡特兰数+逆元)
HDU 4828 Grids 思路:能够转化为卡特兰数,先把前n个人标为0,后n个人标为1.然后去全排列,全排列的数列,假设每一个1的前面相应的0大于等于1,那么就是满足的序列.假设把0看成入栈,1看 ...
- hdu5673 Robot 卡特兰数 / 默慈金数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5673 分析: 这道题是一道裸的默慈金数,比较容易想到的是用卡特兰数来做.不了解的可以先学习一下. 卡特 ...
- hdu 5184(数学-卡特兰数)
Brackets Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...
- hdu_4828_Grids(卡特兰数+逆元)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4828 题意:中文,不解释 题解:实际就是一个卡特兰递推: Catalan(n+1)= Catalan( ...
随机推荐
- gerrit docker运行失败 chown: /var/gerrit/review_site: Permission denied 【已解决】
Docker Volume 之权限管理(转) - jackluo - 博客园 http://www.cnblogs.com/jackluo/p/5783116.html 为什么在公司电脑没有问题,但在 ...
- Serializable 序列化
序列化是指将对象实例的状态存储到存储媒体的过程.在此过程中,先将对象的公共字段和私有字段以及类的名称(包括类所在的程序集)转换为字节流,然后再把字节流写入数据流.在随后对对象进行反序列化时,将创建出与 ...
- php ssh2 scp问题解决
<?php$connection = ssh2_connect('192.168.1.XX', 22);$res=ssh2_auth_password($connection, 'root', ...
- 分析Linux内核创建一个新进程的过程【转】
转自:http://www.cnblogs.com/MarkWoo/p/4420588.html 前言说明 本篇为网易云课堂Linux内核分析课程的第六周作业,本次作业我们将具体来分析fork系统调用 ...
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
出现该问题unspecified on project app resolves to an APK archive which is not supported as a compilation d ...
- python7 静态方法、类方法、属性方法 ;反射;异常处理
#-*- coding:utf8 -*- # 静态方法@staticmethod # 静态方法(当eat变成静态方法后,再通过实例调用时就不会自动把实例本身当作一个参数传给self了.) clas ...
- c3p0数据库连接池(作用不重复)
/* * c3p0数据库连接池: * 只被初始化一次 * connection对象进行close时,不是正的关闭,而是将该数据连接归还给数据库连接池 * * */ 四个架包 mysql-connect ...
- MultiSelectComboBox(二)
1. MainWindow.xaml <Window x:Class="MultiSelectDemo.MainWindow" xmlns="htt ...
- 多校5-MZL's Border 分类: 比赛 2015-08-05 21:28 7人阅读 评论(0) 收藏
MZL's Border Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- POI 简单合并单元格
public class MergedCells { /** 测试使用的POI版本是3.1 * @param args */ public static void main(String[] args ...