Codeforces Bubble Cup 8 - Finals [Online Mirror]H. Bots 数学
H. Bots
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/575/problem/H
Description
Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In each turn, one of the players makes a move (it doesn’t matter which player, it's possible that players turns do not alternate).
Algorithm for bots that Sasha and Ira are developing works by keeping track of the state the game is in. Each time either bot makes a move, the state changes. And, since the game is very dynamic, it will never go back to the state it was already in at any point in the past.
Sasha and Ira are perfectionists and want their algorithm to have an optimal winning strategy. They have noticed that in the optimal winning strategy, both bots make exactly N moves each. But, in order to find the optimal strategy, their algorithm needs to analyze all possible states of the game (they haven’t learned about alpha-beta pruning yet) and pick the best sequence of moves.
They are worried about the efficiency of their algorithm and are wondering what is the total number of states of the game that need to be analyzed?
Input
The first and only line contains integer N.
- 1 ≤ N ≤ 106
Output
Output should contain a single integer – number of possible states modulo 109 + 7.
Sample Input
2
Sample Output
HINT
题意
有两个人,问你两个人都走n次的状态一共有多少种
题解:
打表打表,然后推推数学
推出来是这个:2*(2*n-1)!/(n!*(n-1)!)-1
那就随便搞搞就好啦
代码:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll Mod=1000000007LL;
ll f[];
void build()
{
f[]=1LL;
for(int i=;i<=;i++)
f[i]=i*f[i-]%Mod;
}
ll fp(ll a,ll k)
{
ll res=1LL;
while(k)
{
if(k&)res=res*a%Mod;
a=a*a%Mod;
k>>=;
}
return res;
}
ll C(int n,int k)
{
if(k>n)return 0LL;
return f[n]*fp(f[k],Mod-)%Mod*fp(f[n-k],Mod-)%Mod;
}
int main()
{
build();
int n;
scanf("%d",&n);
n++;
ll ans=(*C(*n-,n)+Mod-)%Mod;
printf("%I64d\n",ans);
}
Codeforces Bubble Cup 8 - Finals [Online Mirror]H. Bots 数学的更多相关文章
- Codeforces Bubble Cup 8 - Finals [Online Mirror] F. Bulbo DP
F. Bulbo Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/F Des ...
- Codeforces Bubble Cup 8 - Finals [Online Mirror] B. Bribes lca
题目链接: http://codeforces.com/contest/575/problem/B 题解: 把链u,v拆成u,lca(u,v)和v,lca(u,v)(v,lca(u,v)是倒过来的). ...
- Codeforces Bubble Cup 8 - Finals [Online Mirror] D. Tablecity 数学题
D. Tablecity Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/575/problem/D ...
- Bubble Cup 12 - Finals Online Mirror, unrated, Div. 1
Bubble Cup 12 - Finals Online Mirror, unrated, Div. 1 C. Jumping Transformers 我会状压 DP! 用 \(dp[x][y][ ...
- Bubble Cup 11 - Finals [Online Mirror, Div. 1]题解 【待补】
Bubble Cup 11 - Finals [Online Mirror, Div. 1] 一场很好玩的题啊! I. Palindrome Pairs 枚举哪种字符出现奇数次. G. AI robo ...
- Bubble Cup X - Finals [Online Mirror] B. Neural Network country 矩阵快速幂加速转移
B. Neural Network country time limit per test 2 seconds memory limit per test 256 megabytes Due to t ...
- Bubble Cup 12 - Finals [Online Mirror, unrated, Div. 1] E. Product Tuples
题意略,题解生成函数练习题,1+(q-ai)x卷积即可,线段树优化(类似分治思想) //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pra ...
- Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 1] K. Lonely Numbers (数学)
题意:定义两个数\(a,b\)是朋友,如果:\(gcd(a,b)\),\(\frac{a}{gcd(a,b)}\),\(\frac{b}{gcd(a,b)}\)能构成三角形,现在给你一个正整数\(n\ ...
- 【简单dfs】Bubble Cup 14 - Finals Online Mirror (Unrated, ICPC Rules, Teams Preferred, Div. 2), problem: (J) Robot Factory,
传送门 Problem - 1600J - Codeforces 题目 题意 给定n行m列, 求每个连通块由多少格子组成,并将格子数从大到小排序输出 对于每个格子都有一个数(0~15),将其转化 ...
随机推荐
- 浅析android下如何通过jni监控wifi网络连接、dhcpcd执行和power电源控制
libs/android_runtime/android_net_wifi_Wifi.cpp部分jni接口static JNINativeMethod gWifiMethods[] = {{ &quo ...
- java jvm学习笔记十一(访问控制器)
欢迎装载请说明出处: http://blog.csdn.net/yfqnihao/article/details/8271665 这一节,我们要学习的是访问控制器,在阅读本节之前,如果没有前面几节的 ...
- Android欢迎界面的创建方法
1.制作一张启动图片splash.png,放置在res->drawable-hdpi文件夹中.2.新建布局文件splash.xml <?xml version="1.0" ...
- DevExpress 中根据数据库字典动态生成卡式菜单 z
第三方的Devexpress套件因为要使用权限机制控制不同用户进入系统显示菜单所以要配合字典数据动态生成.在WEB中这种问题灰常的轻松在winform里就稍微有点不同为了用DEV实现卡式菜单有组的概念 ...
- Casperjs/PhantomJs 中文网站截图乱码
使用CasperJs进行自动化测试中文网站的时候发现中文网站截图会出现乱码的现象,中文汉字被一个个小方框代替 查找了一些资料发现是因为Linux服务器上没有安装中文字体导致的,Linux如何安装中文字 ...
- Loadrunner模拟Json请求
一.loadrunner脚本创建 1.Insert - New step -选择Custom Request - web_custom_request 2.填入相应参数 3.生成脚本,并修改如下(参数 ...
- C#几种截取字符串的方法小结
1.根据单个分隔字符用split截取例如代码如下: string st="GT123_1"; string[] sArray=st.split("_"); 即可 ...
- 教你利用iframe在网页中显示天气
来源:http://www.ido321.com/921.html css: 1: *{margin:0;padding:0;list-style-type:none;} 2: a,img{borde ...
- 【暑假】[实用数据结构]UVa11995 I Can Guess the Data Structure!
UVa11995 I Can Guess the Data Structure! 思路:边读边模拟,注意empty的判断! 代码如下: #include<iostream> #inclu ...
- Tkinter教程之Canvas篇(4)
本文转载自:http://blog.csdn.net/jcodeer/article/details/1812091 '''Tkinter教程之Canvas篇(4)''''''22.绘制弧形'''# ...