No tags yet

No tag edit access

The problem statement has recently been changed. View the changes.

×
time limit per test: 0.25 sec.

memory limit per test: 4096 KB

memory limit per test: 4096 KB

input: standard

output: standard

output: standard

You are given integer numbers N and K and an array D[0..N-1] of decimal digits (0<=D[i]<=9, D[i] is an integer).

Consider an array A of real numbers, such that integer part of A[i] is equal to zero, and fractional part is an infinite decimal fraction with digits D[[(i + 0K) mod N], D[(i + 1K) mod N], D[(i + 2K) mod N] and so on.

For example, for N = 3, K = 2 and D = '194':

A[1] = 0.1491491491...

A[2] = 0.9149149149...

A[3] = 0.4914914914...

You are to find an element of array A with the greatest value and output first N digits of its fractional part.

Consider an array A of real numbers, such that integer part of A[i] is equal to zero, and fractional part is an infinite decimal fraction with digits D[[(i + 0K) mod N], D[(i + 1K) mod N], D[(i + 2K) mod N] and so on.

For example, for N = 3, K = 2 and D = '194':

A[1] = 0.1491491491...

A[2] = 0.9149149149...

A[3] = 0.4914914914...

You are to find an element of array A with the greatest value and output first N digits of its fractional part.

The first line contains integer numbers N and K (1<=N<=150000; 0<=K<=10^9). The second line contains an array of digits D, given without spaces.

You are to output exactly N characters to the output file, according to the task.

Input

Test #1

3 2

194

Test #2

2 1

57

Test #3

4 1

0000

3 2

194

Test #2

2 1

57

Test #3

4 1

0000

Output

Test #1

914

Test #2

75

Test #3

0000

914

Test #2

75

Test #3

0000

Author: | Antony Popovich |

Resource: | --- |

Date: | October, 2003 |

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/25/2021 14:17:15 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|