传送门: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 ,截取和插入一下就好了,水题!

  1. #include<iostream>
  2. #include<algorithm>
  3. #include<string>
  4. #include<cstdio>
  5. #include<cstring>
  6. using namespace std;
  7. int main()
  8. {
       int m,k,T,n;
  9. scanf("%d",&T);
  10. while(T--)
  11. {
  12. string s;
  13. scanf("%d %d",&n,&m);
  14. cin>>s;
  15. int t = n;
  16. while(m--)
  17. {
  18. string s1 = s.substr(t,s.size()-t+);
  19. s.insert(,s1);
  20. }
  21. cout<<s<<endl;
  22. }
  23. }

TOJ 3850: String Function Encoding的更多相关文章

  1. 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- ...

  2. FromBase64String(String)和Encoding.Default.GetBytes(String)

    今天突然被问FromBase64String(String)和Encoding.Default.GetBytes(String)有啥区别,我刚开始学C#对这个一脸懵逼,于是总结一下今天查资料的内容. ...

  3. [转]Date and String Function in BluePrism

    本文转自:https://www.codeproject.com/Articles/1247389/Date-and-String-Function-in-BluePrism This article ...

  4. csharp: string Encoding

    /// <summary> /// 中文转unicode /// </summary> /// <param name="str"></p ...

  5. Node.js Base64 Encoding和Decoding

    如何在Node.js中encode一个字符串呢?是否也像在PHP中使用base64_encode()一样简单? 在Node.js中有许多encoding字符串的方法,而不用像在JavaScript中那 ...

  6. 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 ...

  7. Decode String

    Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where t ...

  8. DiscuzX /source/function/function_core.php通用核心函数库文件分析

    ... <?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to l ...

  9. Chromium String usage

    For Developers‎ > ‎ Chromium String usage Types of StringsIn the Chromium code base, we use std:: ...

随机推荐

  1. react-native 相对项目路径导入组件

    在使用react-native的时候,经常要自定义很多组件,但是只能使用../../../的方式,如果目录多了一长串,书写很烦,看着也不好看. 方法一: 例如你想引入utils里面的文件,不想../. ...

  2. C++中多态中构造函数与析构函数的调用

    做个实验,看一下成员变量的构造析构,父类子类的构造析构,以及虚函数对调用的影响. #include <iostream> using namespace std; class Member ...

  3. 如何玩转小程序+公众号?手把手教你JeeWx小程序CMS与公众号关联

    随着微信小程序新功能.新入口的不断更新,小程序的商业价值逐步增强,特别是小程序与公众号的深度融合,已经让小程序成为各行业新的营销渠道.Jeewx平台专注小程序的开发,逐步完善小程序生态圈,通过简单操作 ...

  4. 【JEECG技术文档】Online唯一校验使用说明

    1.功能介绍 配置了唯一校验的字段,在录入和编辑页面中,动态查询用户输入值是否存在校验. 要使用online唯一校验功能必须先在online表单开发中配置唯一字段的校验方式为唯一校验. 2.配置唯一校 ...

  5. 小麦成长记-<专业盗图好几年>

    ========================================图片来源朋友圈的朋友~

  6. 配置maven访问nexus,配置项目pom.xml以发布maven项目到nexus中

    maven访问nexus有三种配置方法,分别为: 项目pom.xml,优先级最高: user的settings.xml,优先级中,未在pom.xml中配置repository标签,则使用这个配置: m ...

  7. cordova-config.xml配置应用图标

    1. <icon src="res/icon/ios/browser.png"/> 2.规格: iphone平台一般要求3种规格的图片:1x.2x.3x,也是就Icon ...

  8. 尚硅谷springboot学习21-web开发-处理静态资源

    SpringBoot对静态资源的映射规则 @ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFi ...

  9. C++学习二继承

    转载自https://www.cnblogs.com/33debug/p/6666939.html 1.继承与派生  继承是使代码可以复用的重要手段,也是面向对象程序设计的核心思想之一.简单的说,继承 ...

  10. Java学习07 (第一遍) - Spring MVC

    跳过Struts2,直接学习Spring MVC MVC,自己画的 属性(Property/Attribute),事件(Event),方法(method/procedure),函数(Function) ...