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

 19

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 数学的更多相关文章

  1. 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 ...

  2. 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)是倒过来的). ...

  3. 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 ...

  4. 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][ ...

  5. Bubble Cup 11 - Finals [Online Mirror, Div. 1]题解 【待补】

    Bubble Cup 11 - Finals [Online Mirror, Div. 1] 一场很好玩的题啊! I. Palindrome Pairs 枚举哪种字符出现奇数次. G. AI robo ...

  6. 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 ...

  7. 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 ...

  8. 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\ ...

  9. 【简单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),将其转化 ...

随机推荐

  1. Android Failure [INSTALL_FAILED_OLDER_SDK]

    今天编译工程发现 提示“ Failure [INSTALL_FAILED_OLDER_SDK]” 最后发现最小minSdkVersion 超过当前机器的版本,修改配置表中的minSdkVersion, ...

  2. protobuf-3.0.0-beta-2 windows编译 x64/x86

    V3.0.0 beta2以及之后都是CMake 创建VS Solution,project. 因为只能创建x64的项目工程,有时候需要x86的, 只能创建完x64后,自己修改工程配置弄成x86. 创建 ...

  3. 关于KOBE 退役

    今天在网上看到一行话,写在KOBE 退役之际 关于职业,最值得问的是自己我有没有像科比那样始终表现出对团队的忠诚和对职业的热爱?从不被别人的误解和攻击打倒?在团队最困难的时候站出来做能做的一切?用职业 ...

  4. InnoDB一定会在索引中加上主键吗

    InnoDB一定会在索引中加上主键吗 http://www.penglixun.com/tech/database/will_innodb_store_pk_in_index.html

  5. ural 1297(后缀数组+RMQ)

    题意:就是让你求一个字符串中的最长回文,如果有多个长度相等的最长回文,那就输出第一个最长回文. 思路:这是后缀数组的一种常见的应用,首先把原始字符串倒转过来,然后接在原始字符串的后面,中间用一个不可能 ...

  6. Oracle数据库中的违规策略规则的修正

    如笔者计算机上违规的策略与规则: 为了安全,可如下方式对齐进行修正:

  7. Strom-7 Storm Trident 详细介绍

    一.概要 1.1 Storm(简介)      Storm是一个实时的可靠地分布式流计算框架.      具体就不多说了,举个例子,它的一个典型的大数据实时计算应用场景:从Kafka消息队列读取消息( ...

  8. 《Nagios系统监控实践》勘误

    在翻译的过程中,虽然反反复复的检查了很多遍,但依然有所遗漏——这不,今天就收到了 @我是晓梦 的回复,指出了书中的一些错误. 从今天起,建立勘误表,记录这些错误,以便在下一次印刷时纠正,并对广大读者致 ...

  9. DataGird导出EXCEL的几个方法

    DataGird导出EXCEL的几个方法(WebControl) using System;using System.Data;using System.Text;using System.Web;u ...

  10. 求职基础复习之快速排序c++版

    #include<iostream> using namespace std; int partition(int a[],int p,int q){ int x = a[q]; ; fo ...