232. Infinite Fraction
time limit per test: 0.25
sec.
memory limit per test: 4096
KB
input: standard
output: standard
You are given integer numbers N and K and an array D[0..N1] 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.
Input
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.
Output
You are to output exactly N characters to the output file, according to the task.
Sample test(s)
Input
Test #1
3 2
194
Test #2
2 1
57
Test #3
4 1
0000
Output
Test #1
914
Test #2
75
Test #3
0000
Author:  Antony Popovich

Resource:  

Date:  October, 2003

Server time: 20171122 21:05:12  Online Contester Team © 2002  2016. All rights reserved. 

