TOJ 3850: String Function Encoding
传送门:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=3850
时间限制(普通/Java):1000MS/3000MS 内存限制:65536KByte
描述
Bessie discovered a new function that the entire herd can apply to its character strings.
Given both a number N (1 <= N <= 15) and a
string S, with length strictly greater than N, define f(N, S) as a new string
composed
of the concatenation of the substring from character N (zero based
-- first character is number 0) through the end of S and the string S
itself.
For example, with N = 2, and S = "COW", f(N, S) = "W" + "COW" =
"WCOW". Also, f(3, "USACO") = "CO" + "USACO" = "COUSACO".
Bessie is
enthralled with this function and wants to iterate it several times. For
example, if she iterates the function once for
"COW" and N = 2, she will get
"WCOW". If she applies the function with N = 2 again to that string, she will
get "OWWCOW", and if she applies it one more time with N = 2, she will get
"WCOWOWWCOW".
Help Bessie encode a total of Z (1 <= Z <= 100)
strings, str_1, str_2, and so on. Each str_i has length in the range 2..100
and
contains only upper case letters. Each string is presented with its own
N_i (0 <= N_i < length(str_i), and iteration count C_i (1 <= C_i <=
12).
输入
* Line 1: A single integer: Z
* Lines 2..Z+1: Line i+1 contains two
space-separated integers, a space, and string to be encoded: N_i, C_i, and
str_i
输出
* Lines 1..Q: Line j contains the iterated, encoded version of
str_j
样例输入
2
2 3 COW
3 2 USACO
样例输出
WCOWOWWCOW
SACOCOUSACO
提示
OUTPUT DETAILS:
The arrow denotes an iteration of the function
COW -> WCOW -> OWWCOW -> WCOWOWWCOW
USACO -> COUSACO -> SACOCOUSACO
题意:就是把得到的字符串的 从N开始到串结束 这个子串,截取来,放到该串的最前面,这算一次操作
比如说第一组数据,N = 2 ,F =3 代表要执行3次,每次把 第二个位置到最后一位 的子串,截取下来,放到最前面。
思路:拿string里面的substr和insert ,截取和插入一下就好了,水题!
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int m,k,T,n;
scanf("%d",&T);
while(T--)
{
string s;
scanf("%d %d",&n,&m);
cin>>s;
int t = n;
while(m--)
{
string s1 = s.substr(t,s.size()-t+);
s.insert(,s1);
}
cout<<s<<endl;
}
}
TOJ 3850: String Function Encoding的更多相关文章
- SQL:Example Uses of the SUBSTRING String Function
---Example Uses of the SUBSTRING String Function --http://www.sql-server-helper.com/tips/tip-of-the- ...
- FromBase64String(String)和Encoding.Default.GetBytes(String)
今天突然被问FromBase64String(String)和Encoding.Default.GetBytes(String)有啥区别,我刚开始学C#对这个一脸懵逼,于是总结一下今天查资料的内容. ...
- [转]Date and String Function in BluePrism
本文转自:https://www.codeproject.com/Articles/1247389/Date-and-String-Function-in-BluePrism This article ...
- csharp: string Encoding
/// <summary> /// 中文转unicode /// </summary> /// <param name="str"></p ...
- Node.js Base64 Encoding和Decoding
如何在Node.js中encode一个字符串呢?是否也像在PHP中使用base64_encode()一样简单? 在Node.js中有许多encoding字符串的方法,而不用像在JavaScript中那 ...
- Base64 Encoding / Decoding in Node.js
Posted on April 20th, 2012 under Node.js Tags: ASCII, Buffer, Encoding, node.js, UTF So how do you e ...
- Decode String
Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where t ...
- DiscuzX /source/function/function_core.php通用核心函数库文件分析
... <?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to l ...
- Chromium String usage
For Developers > Chromium String usage Types of StringsIn the Chromium code base, we use std:: ...
随机推荐
- idea 安装三方插件的方法
<一>在线安装 1,File -> Setting -> Plugins, 大红框内是已经安装的插件,可以搜索 2, 点击上图小红框内的按钮, 如下,搜索自己想要的插件,选中, ...
- springMVC源码学习之获取参数名
1.入口到参数处理调用流程 入口为spring-webmvc-4.3.18.RELEASE.jar中org.springframework.web.servlet.DispatcherServlet. ...
- VS2003在解决方案范围内搜索卡死问题的解决
在Win7系统上使用VS2003的时候,在解决方案范围内搜索某个内容的时候,VS会卡死. 这是一个兼容性问题,Win7系统对VS2003的兼容性不好, 网上有人讲了一种解决方法是: 在vs2003的图 ...
- 缓存框架有使用过哪些?memcache和redis有什么区别?项目中,怎么去选择?
缓存有:ehcache,memcache和redis等 区别: 1. Redis和Memcache都是将数据存放在内存中,都是内存数据库.不过memcache还可用于缓存其他东西,例如图片.视频等等. ...
- Spring boot 启动配置原理
配置在META-INF/spring.factories 有几个主要的类 ApplicationContextInitializer 创建SpringAplication SpringAppli ...
- Go的50度灰:Golang新开发者要注意的陷阱和常见错误(转)
目录 [−] 初级 开大括号不能放在单独的一行 未使用的变量 未使用的Imports 简式的变量声明仅可以在函数内部使用 使用简式声明重复声明变量 偶然的变量隐藏Accidental Variable ...
- java.util.Arrays$ArrayList addAll报错
执行下面代码时报错: List<String> centerList = WebConstants.SUPPORT_BIG_CENTERS_LIST; // WebConstants.SU ...
- harbor仓库镜像的删除
harbor仓库镜像的删除 刚开始自己摸索了下,直接webui界面删除后,发现仓库空间未释放 上传之前仓库空间占用为 上传之后仓库空间占用为 在webui界面上删除镜像后 查看大小 依旧为286m,到 ...
- Linux性能测试分析命令_sar
sar主要用于收集并统计系统资源的信息,包括CPU.IO.内存.网卡流量等. sar语法 用法:sar [ 选项 ] [ <时间间隔> [ <次数> ] ] 常用选项说明: - ...
- 简单实现"回车!=提交"(去除表单的回车即提交)
-------------------------------------------------------------------------------------------------- 实 ...