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之前那 ...
随机推荐
- MyEclipse设置默认的文档注释和背景色设置
- L121
今天上午签字仪式的布置与该场合的严肃性非常协调.The setting for this morning's signing ceremony matched the solemnity of the ...
- 2018.7.9 AVR-BAT program
I had some problems programming the produced . Here is what worked well for me: -------------------- ...
- mysql索引攻略
本设计和优化专题转自博客园的Mysql的设计和优化专题 Explain优化查询检测 所谓索引就是为特定的mysql字段进行一些特定的算法排序,比如二叉树的算法和哈希算法,哈希算法是通过建立特征值,然后 ...
- python_根据"词库"进行“词联想”
输入法中,当你输入一个字的时候,输入法就能猜出你要输入什么词.这就是词联想.现在,再python中简单实现类似这样的功能:根据制定好的词库,输入一个新的词,帮助实现词联想.其中分词用了jieba包. ...
- swing之记事本的简单实现
package gui1; import java.awt.BorderLayout; import javax.swing.ImageIcon; import javax.swing.JButton ...
- django1.7+nginx1.4.4的static配置
静态文件指像css,js,images之类的文件. 1.工程配置setting.py STATIC_URL = /static/ STATIC_ROOT = /home/www/winingcpi/s ...
- 【转载】Linux 进程调度时间测量
测试Context Switch time(进程上下文切换时间) -------------------------------------------------- 创建两个进程(实时进程) ...
- java代码随机数组合,随机号码产生器
总结:还是掌握方法的运用++++++ package com.c2; //随机数组合,随机号码产生器 //随机号码 import java.util.Random; public class rfe ...
- JS:Window
ylbtech-JS:Window 1.返回顶部 1.happy.js ; (function () { var happyUi = { initHappy: function (type) { ut ...