ARC059F
分析
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 1e9+;
int dp[][],n,m;
char s[];
inline int pw(int x,int p){
x%=mod;
int res=;
while(p){
if(p&)res=(long long)res*x%mod;
x=(long long)x*x%mod;
p>>=;
}
return res;
}
int main(){
int i,j,k;
scanf("%d",&n);
scanf("%s",s);
m=strlen(s);
dp[][]=;
for(i=;i<=n;i++)
for(j=;j<=i;j++){
if(j)dp[i][j]=(dp[i][j]+dp[i-][j-]*)%mod;
if(j==)dp[i][j]=(dp[i][j]+dp[i-][j])%mod;
dp[i][j]=(dp[i][j]+dp[i-][j+])%mod;
}
int Ans=(long long)dp[n][m]*pw(pw(,m),mod-)%mod;
printf("%d\n",Ans);
return ;
}
ARC059F的更多相关文章
- AtCoder 杂题训练
前言: 因为要普及了,今年没一等就可以退役去学文化课了,所以暑假把历年noip普及组都刷了一遍,离noip还有50+天,想弄点强化训练什么的. 想了想,就这些天学文化课之余有空就把AtCoder之前那 ...
随机推荐
- tensorflow中使用tf.ConfigProto()配置Session运行参数&&GPU设备指定
tf.ConfigProto()函数用在创建session的时候,用来对session进行参数配置: config = tf.ConfigProto(allow_soft_placement=True ...
- UVA - 1343 The Rotation Game (BFS/IDA*)
题目链接 紫书例题. 首先附上我第一次bfs+剪枝TLE的版本: #include<bits/stdc++.h> using namespace std; typedef long lon ...
- python发短信功能
http://www.cnblogs.com/martianShu/p/5847289.html
- nodepad++的python环境变量设置
转:http://blog.csdn.net/memray/article/details/42041975
- zabbix监控进程
参考http://chenx1242.blog.51cto.com/10430133/1837990 1 前期说明 zabbix_server查看“文件在后台运行数量”所对应的key就是:proc.n ...
- Rails的静态资源管理(一)——Asset Pipeline是什么
官方文档:http://guides.ruby-china.org/asset_pipeline.html http://guides.rubyonrails.org/asset_pipeline.h ...
- PowerDesigner中的域(Domain)的概念及应用
一.概念 域:实际上就是一个取值范围,也可扩展为一个数据类型.域可以定义检查约束.取值范围.最大值.最小值.默认值等. 域是通过用户自定义类型实现的,定义一个域的后,可以实多个实体的属性共享,这也模型 ...
- JavaScript语言基础-对象与数组
- 类型:NodeJs;问题:默认IE的编码为utf8;结果:IE不能自动选择UTF-8编码解决办法
在Windows操作系统上使用IE作为浏览器时.常常会发生这样的问题:在浏览使用UTF-8编码的网页时,浏览器无法自动侦测(即没有设定“自动选 择”编码格式时)该页面所用的编码.即使网页已经声明过编码 ...
- LNMP 1.4 nginx启动脚本和配置文件
编写Nginx启动脚本,写入下面这段,授权755 vim /etc/init.d/nginx #!/bin/bash # chkconfig: - # description: http servic ...