hdoj 5673 Robot 【默慈金数】
来源:互联网 发布:魅可mac加盟电话 编辑:程序博客网 时间:2024/06/03 18:28
题目链接:hdoj 5673 Robot
有一个机器人位于坐标原点上。每秒钟机器人都可以向右移到一个单位距离,或者在原地不动。如果机器人的当前位置在原点右侧,它同样可以
向左移动单位距离。一系列的移动(左移,右移,原地不动)定义为一个路径。问有多少种不同的路径,使得n秒后机器人仍然位于坐标原点?
答案可能很大,只需输出答案对1,000,000,007的模。
51nod的某一场有这样一道题目。。。
AC代码:
#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>using namespace std;typedef long long LL;const int MAXN = 1e6 + 10;const int MOD = 1e9 + 7;LL pow_mod(LL a, LL n) { LL ans = 1LL; while(n) { if(n & 1LL) { ans = ans * a % MOD; } a = a * a % MOD; n >>= 1LL; } return ans;}LL f[MAXN];void get(){ f[1] = 1LL; f[2] = 2; for(int i = 2; i < 1000000; i++) { f[i+1] = (f[i] * (2 * i + 3) % MOD * pow_mod(i + 3, MOD - 2) % MOD + 3 * i * f[i-1] % MOD * pow_mod(i + 3, MOD - 2) % MOD) % MOD; }}int main(){ get(); int t; scanf("%d", &t); while(t--) { int n; scanf("%d", &n); printf("%I64d\n", f[n]); } return 0;}
0 0
- hdoj 5673 Robot 【默慈金数】
- hdoj-5673-Robot
- hdoj 1035 Robot Motion
- HDOJ 5007 Post Robot
- HDOJ Robot Motion 1035
- Hdoj 1035 Robot Motion
- hdoj-1035Robot Motion
- HDOJ 1035 Robot Motion
- hdoj 1035 Robot Motion 【DFS】
- HDOJ HDU 1035 Robot Motion
- hdoj 1035 Robot Motion (DFS+模拟)
- HDOJ 题目1035 Robot Motion(模拟)
- hdoj 1035 Robot Motion 【DFS 暴力】
- HDOJ(HDU).1035 Robot Motion (DFS)
- hdoj 1035 Robot Motion(简单题)
- HDU 5673 Robot
- HUDOJ 5673 Robot
- HDU 5673 Robot
- 第9周项目3——人数不定的工资类
- hdoj 5672 String 【模拟】
- git使用步骤
- lib静态库、dll动态库
- 【结构型模式】组合模式(Composite)之23种java设计模式
- hdoj 5673 Robot 【默慈金数】
- LeetCode——052
- 使用idfc-proguard-maven-plugin混淆优化Jave Web工程二
- 目标检测的图像特征提取之(一)HOG特征
- 数组长度的获取
- 不得不说的谷歌开发者模式:谷歌调试模式调试js代码总结
- markdown语法之如何使用LaTeX语法编写数学公式
- DIV 内层>DIV相对与外层垂直水平居中
- Android 短信备份完整版