-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotate.java
More file actions
37 lines (31 loc) · 748 Bytes
/
Rotate.java
File metadata and controls
37 lines (31 loc) · 748 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Scanner;
public class Rotate {
public static void main(String [] args){
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int k = scn.nextInt();
int temp = n;
int nod = 0;
while(temp > 0){
temp = temp / 10;
nod++;
}
k = k % nod;
if(k < 0){
k = k + nod;
}
int div = 1;
int mult = 1;
for(int i = 1; i<= nod; i++){
if(i <= k){
div = div * 10;
} else {
mult = mult * 10;
}
}
int q = n / div;
int r = n % div;
int rot = r * mult + q;
System.out.println(rot);
}
}