传送门: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的更多相关文章

  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. MySQL 5.7 以上版本默认禁止 0000-00-00 的日期

    今天做数据同步,发现一直有报错,集中在时间的默认值.数据源的mysql版本是5.5.30,有些时间字段默认值设置为0000-00-00 00:00:00.目标mysql版本为5.7.17,查资料发现, ...

  2. day33-常见内置模块二(hashlib、shutil、configparse)

    一.hashlib算法介绍 Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 1.什么是摘要算法呢? 摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一 ...

  3. mysql每天凌晨0点准时启动taskeng.exe如何关闭

    MySQL弹出一个taskeng.exe. 内容如下:=====================Start Initialization====================mysql Instal ...

  4. Cmake 编译opengl开源库glfw工程及使用

    使用的是cmake gui进行编译的,路径输入好之后,点configure配置vs版本,这里是vs2013版本,然后如果画面出现红色的 需要再点击一下 Generate 然后直接点open proje ...

  5. ABAP-定时-异步

    *&---------------------------------------------------------------------* *& Report ZRICO_TES ...

  6. redis 学习笔记2(集群之哨兵模式的使用)

    redis3.0之前已经有了哨兵模式,3.0之后有了cluster(分片集群),官方不推荐使用!!主要原因是分片后单节点故障后需要实现手动分槽... 集群较为成熟的解决方案codis,公司使用的是哨兵 ...

  7. Servlet基本_画面遷移

    画面遷移方法は.下記ようがある.・リクエストのディスパッチ・リダイレクト(画面から) 1.ディスパッチ1)概念サーブレットから他のリソース(サーブレット.JSP.Htmlなど)にリクエストを転送するこ ...

  8. 解决 'Could not convert variant of type (NULL) into type (String)

    写存储过程中有不允许为空的字段,在客户端转化取数时显示 Could not convert variant of type (NULL) into type (String) 可以在存储过程中使用is ...

  9. git 每次push都需要输入用户和密码

    git remote -v origin https://github.com/userName/xx.git (fetch) origin https://github.com/userName/x ...

  10. 【剑指offer】单链表尾部插入一个节点

    #include <iostream> using namespace std; //链表结构体 struct ListNode { int m_Value; ListNode *next ...