HDU5673 Robot 默慈金数
分析:

注:然后学了一发线性筛逆元的姿势
链接:http://blog.miskcoo.com/2014/09/linear-find-all-invert
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int N=1e6+;
const LL mod=1e9+;
LL f[N],inv[N];
int main(){
inv[]=;
for(int i=;i<N;++i)
inv[i]=inv[mod%i]*(mod-mod/i)%mod;
f[]=;
f[]=;
for(int i=;i<=N-;++i)
f[i]=((*i+)*f[i-]%mod+(*i-)*f[i-]%mod)%mod*inv[i+]%mod;
int T,n;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
printf("%I64d\n",f[n]);
}
return ;
}
HDU5673 Robot 默慈金数的更多相关文章
- hdu-5673 Robot(默次金数)
题目链接: Robot Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) 问题描述 ...
- hdu5673 Robot 卡特兰数 / 默慈金数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5673 分析: 这道题是一道裸的默慈金数,比较容易想到的是用卡特兰数来做.不了解的可以先学习一下. 卡特 ...
- 51nod1556 计算(默慈金数)
Problem 有一个\(1*n\)的矩阵,固定第一个数为\(1\),其他填正整数, 且相邻数的差不能超过\(1\),求方案数. \(n\le 10^6\) Solution 容易发现答案是\(f_n ...
- 51 Nod 1556计算(默慈金数的应用)
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; typedef long long ll; ll m ...
- Python 素数判断;以及默尼森数
1. 素数/质数 只能被2或者本身整除的正整数. 2. 默尼森数 P是素数且M也是素数,并且满足等式M=2^P-1,则称M为默尼森数. 编程小要求: 输出前5个默尼森数 1)最外层循环找素数 中间层循 ...
- Python实现的寻找前5个默尼森数算法示例
Python实现的寻找前5个默尼森数算法示例 本文实例讲述了Python实现的寻找前5个默尼森数算法.分享给大家供大家参考,具体如下: 找前5个默尼森数. 若P是素数且M也是素数,并且满足等式M=2* ...
- hdu5673 Robot 卡特兰数+组合数学+线性筛逆元
Robot Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Subm ...
- Robot(hdu5673)
Robot Accepts: 92 Submissions: 188 Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 ...
- 北京培训记day1
数学什么的....简直是丧心病狂啊好不好 引入:Q1:前n个数中最多能取几个,使得没有一个数是另一个的倍数 答案:(n/2)上取整 p.s.取后n/2个就好了 Q2:在Q1条件下,和最小为多少 答 ...
随机推荐
- 【应用】:shell crontab定时生成oracle表的数据到txt文件,并上传到ftp
一.本人环境描述 1.oracle服务端装在win7 32位上,oracle版本为10.2.0.1.0 2.Linux为centos6.5 32位,安装在Oracle VM Vir ...
- Git-it:一个学习Git和Github的教程(软件)
Git-it https://github.com/jlord/git-it 2016-08-01 在FreeCodeCamp的引导下了解到的Git-it.OSC有收录. Git-it是一个指导使用G ...
- Newtonsoft.Json.dll解析json的dll文件使用
要解析的json //解析前 //解析前 {,,,,,,,,,,},,,,,,,,,,,},,,,,,,,,,,,,,,,},,,,,,,,,},,,,,,,,,,,,},,,,,,,,,,,},,, ...
- Delphi中的GetEnumName和GetEnumValue的使用方法
利用TypInfo单元的GetEnumName和GetEnumValue可以遍历任意枚举类型,并获取其名称和值.下面是示例Demo. uses TypInfo; ... procedure TForm ...
- NodeJS+ExpressJS+SocketIO+MongoDB应用模板
OS:Win8.1 with update 关键字:NodeJS,ExpressJS,SocketIO,MongoDB. 1.源代码下载:https://github.com/ldlchina/ESM ...
- 2016030206 - mysql常用命令
参考地址如下: http://www.cnblogs.com/linjiqin/archive/2013/03/01/2939384.html http://www.cnblogs.com/zhang ...
- HBase Shell(转)
HBase 为用户提供了一个非常方便的使用方式, 我们称之为“HBase Shell”.HBase Shell 提供了大多数的 HBase 命令, 通过 HBase Shell 用户可以方便地创建.删 ...
- 【intellij】异常信息汇总
Application Server was not connected before run configuration stop, reason: javax.management.Instanc ...
- Git权威指南 读笔(3)
第九章 恢复进度: $ git stash list 显示存储的工作进度列表. $ git stash 保存当前的工作进度,分别对暂存区和工作区的状态进行保存. $ git stash pop [-- ...
- EL四大作用域 9个jsp对象有效范围 及 对应的类
java中request,session,application的作用范围 page,request,session,application四者的作用范围: page的作用范围是当前页面:对应El表达 ...