H. Fake News (medium)
H. Fake News (medium)
题意
以前是给出 S T 串,问在 S 中有多少个子串为 T 的个数,子串可以不连续,保持位置相对一致。
现在给出 n ,要你构造 S T 串。
分析
这种 special judge 的题目也是清奇。
设 S 为文本串,p 为模式串,设 S = p + u,初始设 p = "a",u 为空串,那么初始 S 串中匹配到的数量 k = 1,
- 1 -> 2 ,设 z 为未出现过的字母,那么 p = p + z ,u = u + z,S = pzz(u 从空串变成 z),
- k -> 2k+1,那么 p = p + z,u = u + z + z,后面的 uzz 对应 2k,加上前面的 pz 对应 1,
- k -> 2k+2,p = p + z,u = z + u + z + z,那么 S = pzzuzz 。
code
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
string p, u;
char c;
void so(int n) {
if(n == 1) {
p = "";
c = 'a';
p += c;
u = "";
c++;
} else if(n == 2) {
so(n / 2);
p = p + c;
u = u + c;
c++;
} else {
if(n & 1) {
so((n - 1) / 2);
p = p + c;
u = u + c + c;
c++;
} else {
so((n - 2) / 2);
p = p + c;
string c_;
c_ += c;
u = c_ + u + c + c;
c++;
}
}
}
int main() {
int n;
while(cin >> n) {
so(n);
cout << p + u << " " << p << endl;
}
return 0;
}
H. Fake News (medium)的更多相关文章
- Codeforces 802 补题
codeforces802 A-O Helvetic Coding Contest 2017 online mirror A Heidi and Library (easy) 水题 同B #incl ...
- Brain Network (medium)(DFS)
H - Brain Network (medium) Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d &am ...
- Detailed Information for Outputted Files from Somatic Mutation Annotators(annovar 注释文件条目详细解释)
CONTENTS *_annoTable.txt (ANNOVAR) *_annoTable.txt (SnpEff) *_genelist.txt (ANNOVAR & SnpEff) db ...
- Swift LeetCode 目录 | Catalog
请点击页面左上角 -> Fork me on Github 或直接访问本项目Github地址:LeetCode Solution by Swift 说明:题目中含有$符号则为付费题目. 如 ...
- OpenTelemetry-可观察性的新时代
有幸在2019KubeCon上海站听到Steve Flanders关于OpenTelemetry的演讲,之前Ops领域两个网红项目OpenTracing和OpenCensus终于走到了一起,可观察性统 ...
- fake gucci outlet perform a couple associated with things in great trust
Based on my a lot of years of encounter within Taobao, purchase bags must go to the high reputation ...
- x264 - 高品质 H.264 编码器
转自:http://www.5i01.cn/topicdetail.php?f=510&t=3735840&r=18&last=48592660 H.264 / MPEG-4 ...
- 转:MediaCoder H.264格式编码参数设置及详解
转: http://mediacoder.com.cn/node/81 由于现在大部分视频转码都选择H.264格式进行编码,同时CUDA编码的画质还达不到x264软编码的质量(如果你对画质无要求,可以 ...
- stm32f10x.h文件分析理解
今天再看过半年前自己写的这篇发现自己当时理解有误,stm32f10x.h与库开发并未存在太大关系,只是一个最为重要的寄存器地址到寄存器结构体变量的映射. stm32f10x.h 这个头文件是STM32 ...
随机推荐
- 【APUE】Chapter9 Process Relationships
这一章看的比较混乱,可能是因为例子少:再有就是,这一章就是一个铺垫的章节. 9.2 terminal logins 啥叫termnial? 我感觉书上的terminal指的更可能是一些物理设备(key ...
- Asp.net获取网站绝对路径的几种方法
在编写ASP.NET应用程序的时候,有时候为了更好的进行控制静态文件的路径,以及网站部署过程中的虚拟路径等问题,采用绝对路径避免资源出现Not Found,下面先看看几种获取绝对路径的方法: 1. 以 ...
- 课时40:类与对象:一些相关的BIF
目录: 一.一些相关的BIF 二..课时40课后习题及答案 ********************** 一.一些相关的BIF ********************** 1.issubclass( ...
- 对于进程没杀死占用内存和cpu行为的方法
在跑机器学习或者深度学习的过程中有可能遇到没杀死进程的情况,但是程序的入口又没关掉,尤其是我使用jupyter从远程Linux映射到windows浏览器跑程序的时候 对于上面的问题, 首先运行 hto ...
- Ubuntu下禁用笔记本自带键盘
想要禁用笔记本自带键盘(Ubuntu)只要2条命令. 1. 打开终端,输入: xinput list ⎡ Virtual core pointer id=2 [master pointer (3)] ...
- 普通用户操作tomcat项目时报:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program
在使用普通用户更新tomcat项目适合出现这个信息,Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At ...
- UVALive 6324 Archery (求射箭覆盖的期望)
#include<cstdio> #include<cmath> #include<cstring> #include<cstdlib> const d ...
- c#中onclick事件请求的两种区别
在C#中如果是asp控件的button有两个click的调用,一个是OnClick,一个是OnClientClick.那么这两者有什么区别呢,下面就来说说区别. <asp:Button ID=& ...
- Qt-Creator 加入qwt库
qwt是基于Qt的开源图表库 从官网下载qwt的源码 http://sourceforge.jp/projects/sfnet_qwt/downloads/qwt/6.1.0/qwt-6.1.0.ta ...
- swagger-ui enum select
swagger-ui enum select Array[string] https://dejanstojanovic.net/aspnet/2018/march/displaying-multip ...