Hidden Message
Hidden Message
- 比赛主页
- 我的提交
时间限制:C/C++ 2秒,其他语言4秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
John was reading the local newspaper, and noticed that the phrase “chime a cork teen” could be
split into three sub-phrases “eat”, “more”, and “chicken”. Note that the three sub-phrases
combined contain exactly the same letters as the original phrase and the letters in each sub-phrase
appear in the same order as they appear in the original phrase. Note also that the number of
occurrences of each letter in the three sub-phrases combined is the same as that of the original
phrase.
John began to theorize that the newspapers were sending him messages, but you decide to show
him that a message like that was not abnormal. You want to determine the number of ways a
phrase can be broken down into three words that John finds.
Given three sub-phrases and the original phrase, determine the number of ways the sub-phrases
can be formed from the original phrase. The number of ways can be quite large, so determine the
number modulo 1,000,000,007.
输入描述:
The input consists of four lines. Each of the first three input lines contains 1-100 lowercase letters, representing a sub-phrase. The fourth input line contains 3-300 lowercase letters, representing the original phrase. Note that the sum of the lengths of the three sub-phrases is equal to the length of the original phrase.
输出描述:
Print a single integer representing the number of ways to partition the original phrase into three groups where each group is one of the three sub-phrases. Print the count modulo 1,000,000,007.
示例1
输入
复制
eat more chicken chimeacorkteen
输出
复制
2
示例2
输入
复制
the great depression depressigortheneat
输出
复制
2
示例3
输入
复制
a a a aaa
输出
复制
6
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll dp[200][200][200];
const int maxn=100010;
int main(){char a[110];char b[110];char c[110];char d[500];int la,lb,lc,ld;cin>>a+1>>b+1>>c+1>>d+1;la=strlen(a+1);lb=strlen(b+1);lc=strlen(c+1);ld=strlen(d+1);dp[0][0][0]=1;for(int i=1;i<=ld;i++){for(int j=0;j<=la;j++){for(int k=0;k<=lb;k++){for(int l=0;l<=lc;l++){if(j+k+l!=i) continue;if(d[i] == a[j] && j - 1 >= 0) dp[j][k][l] += dp[j-1][k][l] % mod;if(d[i] == b[k]&& k - 1 >= 0) dp[j][k][l] += dp[j][k-1][l] % mod;if(d[i] == c[l]&& l - 1 >= 0) dp[j][k][l] += dp[j][k][l-1] % mod;}}}}cout<<dp[la][lb][lc]%mod;
}
Hidden Message相关推荐
- URAL 题目1297. Palindrome(后缀数组+RMQ求最长回文子串)
1297. Palindrome Time limit: 1.0 second Memory limit: 64 MB The "U.S. Robots" HQ has just ...
- CPU8085 8086名字的由来
为什么CPU叫8085呢? 8085这个名字的由来还是很有逻辑的:The naming of microprocessor indicates historical facts blended wit ...
- 重力传感器 测重力代码_“重力瀑布”如何帮助您教授孩子的密码学基础知识...
重力传感器 测重力代码 by Kamil Tustanowski 通过卡米尔·图斯坦诺夫斯基 "重力瀑布"如何帮助您教授孩子的密码学基础知识 (How "Gravity ...
- URAL1297 Palindrome【manacher算法】
1297. Palindrome Time limit: 1.0 second Memory limit: 64 MB The "U.S. Robots" HQ has just ...
- 2021-06-14 Socketio学习使用搭建一个聊天室
Socketio搭建一个聊天室 前言 本次实验所用编程语言为HTML以及javascript和JQurey语言和Socketio框架,所用编辑文本工具为VS code. 注意事项 (1)前端编程注意H ...
- 浙江大学计算机学院 金小刚,金小刚(浙江大学CADCG国家重点实验室教授)_百度百科...
Bo Wang,Quan Chen,Min Zhou,Zhiqiang Zhang,Xiaogang Jin,Kun Gai,"Progressive Feature Polishing N ...
- CAPICAPICOM的一些知识
CAPI&CAPICOM的一些知识 2007-06-09 22:09 1 引言 CryptoAPI(一个应用程序编程接口)目的就是提供开发者在Windows 下使用PKI 的 ...
- CAPICAPICOM的一些知识[转]
1 引言 CryptoAPI(一个应用程序编程接口)目的就是提供开发者在Windows 下使用PKI 的编程接口.CryptoAPI 提供了很多函数,包括编码.解码.加密.解密.哈希 ...
- 用 websocket、JQuery开发仿微信聊天
1项目展示 登陆界面 不同的端口 登陆 属于不同的用户 登陆两个端口号后的 界面 2项目基本配置 2.1参考文档 socket.io 先引入 socket.io插件 npm install --sav ...
最新文章
- Openssl req命令
- sklearn基本回归方法
- C#使用Xamarin开发可移植移动应用进阶篇(6.使用渲染器针对单个平台自定义控件),附源码
- gin+vue的前后端分离开源项目
- 数据结构学习笔记:变位词侦测案例
- 手机自动化测试IDE --手把手教你用Airtest模拟器来连接手机
- 告别乱码,针对GBK、UTF-8两种编码的智能URL解码器的java实现
- STC学习:八位数码管滚动显示
- Open3D绘制3D坐标,绘制点云
- java电表抄表器接口_远程抄表系统接线图和远程抄表电表安装图及实例
- flex实现三栏布局
- 随手记录: 扩展M.2硬盘,从1T换到2T 硬盘clone ubuntu设置等注意事项
- .Net Core裁剪图片并存入数据库
- 基于STM32F103ZET6主控平台实现电容触摸按键 [基于TIM5_CH2(PA1)的输入捕获]
- Android AsyncTask 接口回调
- c语言中0x11是多少,C语言中的符号
- 中山大学羽毛球场馆自动订场(Python+selenium+百度aip)
- pygame-KidsCanCode系列jumpy-part18-背景滚动
- Android 常用备忘
- 高级信息项目管理师规划