-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5.6 - Mecanism Seif.java
39 lines (29 loc) · 1.06 KB
/
5.6 - Mecanism Seif.java
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
38
39
import java.util.*;
public class teianu{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
String line=sc.nextLine();
String []numbers=line.trim().split("\\s+");
int r=sc.nextInt();
int []sens=new int[r];
int []nrPoziti=new int[r];
LinkedList<Integer> list=new LinkedList<Integer>();
for(int k=0;k<6;k++){
list.add(Integer.parseInt(numbers[k]));
}
sc.nextLine();
int valueToRotate=0;
for(int i=0;i<r;i++){
String line2=sc.nextLine();
String[] parts2=line2.trim().split("\\s+");
sens[i]=Integer.parseInt(parts2[0]);
nrPoziti[i]=Integer.parseInt(parts2[1]);
if(sens[i]>0){
valueToRotate+=nrPoziti[i];
}else if(sens[i]<0){
valueToRotate=valueToRotate-nrPoziti[i];
}
}
System.out.println(list.get(valueToRotate));
}
}