ACM:S: 取字符串

xiaoxiao2021-02-28  116

ACM:S: 取字符串

Description

有个长度为1000000以内的字符串C,提供整数a,b,d,e,计算ans=a*b%d,然后取C从第e(e的取值从0开始)号位置的字符开始长度为ans的那子串并输出。(1<=a,b<=5000)数据保证子串不超过C的字符串范围。

Input

 有多组测试数据,对于每组数据,第一行为4个整数,a,b,d,e,第二行为给定的字符串C。

Output

对于每组测试数据,输出所求的子字符串。

Sample Input

3 4 5 1 abcdefghijk

Sample Output

bc 利用substr()函数,特别简单。 #include <iostream>#include <cstdio>#include <cstring>#include <vector>#include <cmath>#include <algorithm>#include <string>#include <ctime>#define LL long long#define MAX(a,b)((a)>(b)?a:b)#define MIN(a,b)((a)<(b)?a:b)#define INF 0x7ffffff#define N 105#define M 15using namespace std;int a[N];char s[10],c[10];int main(){ int a,b,d,e; string str; while(cin>>a>>b>>d>>e) { cin>>str; cout<<str.substr(e,a*b%d)<<endl; } return 0;}
转载请注明原文地址: https://www.6miu.com/read-20605.html

最新回复(0)