#K57362. Rotate Digits

    ID: 30404 Type: Default 1000ms 256MiB

Rotate Digits

Rotate Digits

Given an integer \( n \) and a non-negative integer \( k \), rotate the digits of \( n \) in a circular fashion by \( k \) positions. In a circular rotation, the last \( k \) digits of \( n \) are moved to the beginning, while the rest of the digits are shifted to the right. If \( k \) is greater than or equal to the number of digits in \( n \), only the remainder when \( k \) is divided by the number of digits is considered.

Formally, if \( n \) has \( d \) digits and we define \( k' = k \bmod d \), then the rotated number \( R \) is obtained by concatenating the last \( k' \) digits of \( n \) with the first \( d-k' \) digits. That is, if \( n \) is represented as a string \( s \), then \[ R = \text{int}(s_{d-k':d} + s_{0:d-k'}) \]

You are required to implement this rotation operation.

inputFormat

The input consists of a single line containing two space-separated integers. The first integer is ( n ), the number whose digits are to be rotated, and the second integer is ( k ), the number of positions to rotate.

outputFormat

Output a single integer which is the result of rotating ( n ) by ( k ) positions.## sample

12345 2
45123

</p>