A. Many Equal Substrings(水题)
思路:
直接比较橘色框里的取第一次相等,即可。

#include<iostream>
#include<string>
using namespace std; string x, y;
int n, m, k; int main(){
cin>>n>>m;
cin>>x;
for(int i=;i<n;++i){
if(x.substr(i, n)==x.substr(, n-i)){y=x.substr(n-i, n); k=; break;}
}
if(k){
cout<<x;
for(int i=;i<m-;++i)
cout<<y;
cout<<endl;
}else{
for(int i=;i<m;++i)
cout<<x;
cout<<endl;
}
}
A. Many Equal Substrings(水题)的更多相关文章
- Codeforces Round #306 (Div. 2) A. Two Substrings 水题
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...
- Codeforces Round #258 (Div. 2) D. Count Good Substrings 水题
D. Count Good Substrings 题目连接: http://codeforces.com/contest/451/problem/D Description We call a str ...
- Educational Codeforces Round 2 B. Queries about less or equal elements 水题
B. Queries about less or equal elements Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforc ...
- 水题 Codeforces Round #306 (Div. 2) A. Two Substrings
题目传送门 /* 水题:遍历一边先找AB,再BA,再遍历一边先找BA,再AB,两种情况满足一种就YES */ #include <cstdio> #include <iostream ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)
B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- codeforces 677A A. Vanya and Fence(水题)
题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- poj1564 Sum It Up dfs水题
题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using n ...
随机推荐
- Java垃圾回收器的工作原理
上课,老师照本宣科,实在难以理解,干脆就看书包里的Java书,正好看了Java的垃圾回收器是如何工作的,觉得有必要记录一下. 参考于 Java编程思想第四版(Thinking in Java) 老年代 ...
- java package(包)的用法
一般来说都用eclipse自动化图形工具搞定,我用的是ubuntu,所以需要自己打包引入. 什么是包? 这是对java源代码的组织和管理的一种方式,比如:当操作系统某个目录的文件非常多的时候,我们一般 ...
- nodejs+expressjs+ws实现了websocket即时通讯,服务器和客户端互相通信
nodejs代码 // 导入WebSocket模块: const WebSocket = require('ws'); // 引用Server类: const WebSocketServer = We ...
- 【20190220】JavaScript-知识点整理:对象创建方式、原型、闭包
一.对象创建方式 1. 工厂模式 这种模式抽象了创建具体对象的过程,用函数来封装以特定接口创建对象的细节.存在的问题是无法通过 instanceof 识别一个对象的类型. function creat ...
- springboot Redis 缓存
1,先整合 redis 和 mybatis 步骤一: springboot 整合 redis 步骤二: springboot 整合 mybatis 2,启动类添加 @EnableCaching 注解, ...
- IDEA基于Maven Struts2搭建配置及示例
1.web.xml加载struts框架即过滤器,要注意struts版本不同过滤器配置也不同. <!DOCTYPE web-app PUBLIC "-//Sun Microsystems ...
- Centos 7 查看内存占用情况相关命令
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/80652626 本文出自[赵彦军的博客] 1. top命令 top命令经常用来监控l ...
- 章节三、5-Getters-Setters和this关键字part01
我们新建第一个Car类: package introduction; public class Car { //颜色 private String color; //生成商 private Strin ...
- (网页)HTMl5的sessionStorage和localStorage
百度上百度的,记录一下: html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage. sessionStorage用于本地存储一个会话(sessi ...
- 如何在 Flickr 上找到又酷,又有趣,且版权自由的照片?
[编者按]本文作者为 Alex Walker,主要介绍在 Flickr 上进行照片搜索时的一些技巧.本文系国内 ITOM 管理平台 OneAPM 编译呈现. 我们一直都在寻找新奇的,与众不同的设计.图 ...