File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .*;
2
+ import java .util .ArrayList ;
3
+ import java .util .Arrays ;
4
+ public class Main {
5
+ public static void main (String [] args ) throws IOException {
6
+ File file = new File (args [0 ]);
7
+ BufferedReader br = new BufferedReader (new FileReader (file ));
8
+ String line ;
9
+ while ((line = br .readLine ()) != null ) {
10
+ String [] a = line .substring (0 , line .length ()-4 ).split (" " );
11
+ int b = Integer .parseInt (line .substring (line .length ()-2 ).trim ());
12
+ ArrayList <String > ai = new ArrayList <String >(Arrays .asList (a ));
13
+ while (ai .size ()>1 ) {
14
+ if (b >ai .size () && (b %ai .size ()!=0 )) {
15
+ ai .remove ((b %ai .size ()-1 ));
16
+ }
17
+ else if ((b %ai .size ()==0 )) {
18
+
19
+ ai .remove (ai .size ()-1 );
20
+ }
21
+ else {
22
+ ai .remove (b -1 );
23
+ }
24
+ }
25
+ System .out .println (ai .get (0 ));
26
+ }
27
+ br .close ();
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments