P18197 [HackerRank] Repeated string
普及-
题目描述

There is a string, $unrecognized$, of lowercase English letters that is repeated infinitely many times. Given an integer, $unrecognized$, find and print the number of letter a's in the first $unrecognized$ letters of the infinite string.

Example

$unrecognized$

$unrecognized$

The substring we consider is $unrecognized$, the first $unrecognized$ characters of the infinite string. There are $unrecognized$ occurrences of a in the substring.

Function Description

Complete the repeatedString function in the editor below.

repeatedString has the following parameter(s):

s: a string to repeat
n: the number of characters to consider

Returns

int: the frequency of a in the substring

Input Format

The first line contains a single string, $unrecognized$.

The second line contains an integer, $unrecognized$.

Constraints

$unrecognized$
$unrecognized$
For $unrecognized$ of the test cases, $unrecognized$.

Sample Input

Sample Input 0

aba
10

Sample Output 0

7

Explanation 0

The first $unrecognized$ letters of the infinite string are abaabaabaa. Because there are $unrecognized$ a's, we return $unrecognized$.

Sample Input 1

a
1000000000000

Sample Output 1

1000000000000

Explanation 1

Because all of the first $unrecognized$ letters of the infinite string are a, we return $unrecognized$.

输入格式

见题面

输出格式

见题面

样例输入
aba 10
样例输出
7