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之前那 ...
随机推荐
- web.xml & web-fragment.xml (Servlet 2.3, 2.4, 2.5 + 3.0)模板
转自:http://jlcon.iteye.com/blog/890964 web.xml v2.3 <?xml version="1.0" encoding="I ...
- 「长乐集训 2017 Day1」区间 线段树
题目 对于两个区间\((a,b),(c,d)\),若\(c < a < d\)或\(c < b < d\)则可以从\((a,b)\)走到\((c,d)\)去,现在有以下两种操作 ...
- 使用POI导出excel基础篇
最近搞了下POI导出Excel,听说很多次,却是第一次搞. 在pom.xml中引入依赖 <dependency> <groupId>org.apache.poi</gro ...
- [转]Cache-Control max-age=0
Cache-Control max-age=0 Cache-Control no-cache — 强制每次请求直接发送给源服务器,而不经过本地缓存版本的校验.这对于需要确认认证应用很有用(可以和 ...
- 异常[PersistenceUnit: default] Unable to build Hibernate SessionFactory
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManage ...
- RazorHelper.cs
完整版 RazorHelper.cs using System; using System.Collections; using System.Collections.Generic; using S ...
- Python运行错误解释
BaseException 所有异常的基类 SystemExit 解释器请求退出 KeyboardInterrupt 用户中断执行(通常是输入^C) Exception 常规错误的基类 StopIte ...
- java流类基础练习。
总结:BufferedReader.InputStreamReader.字节与字符的区别. package com.ds; import java.io.*; //从控制台输入字符串,输到sdd时停止 ...
- 未在本地计算机上注册 Microsoft.ACE.OLEDB.12.0 提供程序
Visual Studio 8使用了Access数据库,provider选择了ACE.OLEDB,但是运行时出现了错误,提示未在本地计算机上注册"Microsoft.ACE.OLEDB.12 ...
- 获取Linux权限后安装rootkit
1.首先获得远程服务器的root权限,当然这是基本的也是最难的. 2.然后下载rootkit程序,本文用到的是mafix. 3.开始安装 wget http://godpock.googlecode. ...