hdu 4869
一个机智题,可惜比赛的时候没有机智出来
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
#define mod 1000000009
#define maxn 100009
using namespace std; ll c[maxn]; void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
if(b==)
{
d=a;
x=;
y=;
}
else
{
gcd(b,a%b,d,y,x);
y-=x*(a/b);
}
} ll inv(ll a,ll n)
{
ll d,x,y;
gcd(a,n,d,x,y);
return d==?(x+n)%n:-;
} int main()
{
int m,x,n;
while(scanf("%d%d",&m,&n)!=EOF)
{
int low=,up=;
int loww=,upp=;
for(int i=; i<m; i++)
{
scanf("%d",&x);
loww=n-up;
upp=n-low;
if(up>x&&low<x)
low=(up-x)%;
else if(up<=x)
low=abs(up-x);
else if(low>=x)
low=abs(low-x); if(upp>x&&loww<x)
loww=(upp-x)%;
else if(upp<=x)
loww=abs(upp-x);
else if(loww>=x)
loww=abs(loww-x);
up=n-loww;
}
// printf("%d %d\n",low,up);
c[]=;
ll ans=;
for(int i=; i<=n; i++)
{
c[i]=(c[i-]*(n-i+)%mod*inv(i,mod))%mod;
}
for(int i=low; i<=up; i+=)
{
ans+=c[i];
ans%=mod;
}
printf("%I64d\n",ans);
}
return ;
}
hdu 4869的更多相关文章
- HDU 4869 (递推 组合数取模)
Problem Turn the pokers (HDU 4869) 题目大意 有m张牌,全为正面朝上.进行n次操作,每次可以将任意ai张反面,询问n次操作可能的状态数. 解题分析 记正面朝上为1,朝 ...
- HDU 4869 Turn the pokers(推理)
HDU 4869 Turn the pokers 题目链接 题意:给定n个翻转扑克方式,每次方式相应能够选择当中xi张进行翻转.一共同拥有m张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...
- hdu 4869 Task(馋)
题目链接:hdu 4869 Task 题目大意:有n台机器,m个任务.每一个机器和任务都有有xi和yi.要求机器的xi.yi均大于等于任务的xi和yi才干运行任务. 每台机器一天仅仅能运行一个任务.要 ...
- hdu 4869 Turn the pokers (2014多校联合第一场 I)
Turn the pokers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 4869 Turn the pokers(思维+组合公式+高速幂)
pid=4869" target="_blank">Turn the pokers 大意:给出n次操作,给出m个扑克.然后给出n个操作的个数a[i],每一个a[i] ...
- 2014多校第一场 I 题 || HDU 4869 Turn the pokers(费马小定理+快速幂模)
题目链接 题意 : m张牌,可以翻n次,每次翻xi张牌,问最后能得到多少种形态. 思路 :0定义为反面,1定义为正面,(一开始都是反), 对于每次翻牌操作,我们定义两个边界lb,rb,代表每次中1最少 ...
- HDU 4869 Turn the pokers (2014 Multi-University Training Contest 1)
Turn the pokers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu 4869 Turn the pokers(组合数+费马小定理)
Problem Description During summer vacation,Alice stay at home for a long time, with nothing to do. S ...
- HDU 4869 Turn the pokers (2014 多校联合第一场 I)
HDOJ--4869--Turn the pokers[组合数学+快速幂] 题意:有m张扑克,开始时全部正面朝下,你可以翻n次牌,每次可以翻xi张,翻拍规则就是正面朝下变背面朝下,反之亦然,问经过n次 ...
随机推荐
- PHP的final、抽象类和方法
final关键字的用法 final class Computer{ //无法继承的类 final public function run(){ //无法继承的方法 } } class NoteBook ...
- CSS伪对象选择符整理
1.E::selection 2.E::placeholder 1. E::selection 设置对象被选择时的样式. 需要注意的是,::selection只能定义被选择时的background-c ...
- Myeclipse安装svn插件(link方式)
Myeclipse安装svn插件(link方式) 优点:1.离线安装2.非侵入式 演示版本 myeclipse--myeclipse8.6 svn--subeclipse-site-1.6.5.zip ...
- 纪念一下自己的第一篇cnblog
2016-08-1016:33:22 // Netease.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<iost ...
- Spring MVC与easyui国际化
1.建立资源文件 在webapp下建立文件夹language,在其中再添加file,命名分别为language.properties,language_en.properties,language_z ...
- mysql主从复制-linux版本
来自:http://www.osyunwei.com/archives/7269.html,改版 mysql主从复制本文采用的是centos6.5+mysql-5.6.23版本之前在 windows7 ...
- canvas 绘点图
canvas 绘点图 项目中需要一个记录点实时变动的信息,在此记录一下: <!DOCTYPE html> <html lang="en"> <head ...
- 在有跳板机的情况下,SecureCRT自动连接到目标服务器
为了服务器的安全,运维人员经常会要求我们先登录到跳板机,然后再SSH连接到目标服务器.但是这样是很繁琐的,每次在SecureCRT创建一个连接,都需要输入SSH命令,然后输入密码. 下面的方法可以实现 ...
- cadence16.6 如何对齐元件
1.选中Setup-->Application Mode-->Placement Edit mode2.按"CTRL"键,选中需要对齐的所有对象.3.点击右键右,或者在 ...
- .NET特性-Attribute
两篇文章有助于学习Attribute特性的概念. http://blog.csdn.net/byondocean/article/details/6802111 http://www.cnblogs. ...