-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcombo.java
More file actions
120 lines (108 loc) · 3.57 KB
/
Copy pathcombo.java
File metadata and controls
120 lines (108 loc) · 3.57 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
ID: adimagg1
LANG: JAVA
TASK: combo
*/
import java.io.*;
import java.util.*;
class combo {
public static void main (String [] args) throws IOException {
// Use BufferedReader rather than RandomAccessFile; it's much faster
File f = new File("combo.in");
Scanner in = new Scanner(f);
// input file name goes above
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("combo.out")));
int n = in.nextInt();
ArrayList<String> ar = new ArrayList<String>();
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int d = in.nextInt();
int e = in.nextInt();
int g = in.nextInt();
if(n ==1){
out.println(1);
}else if(n==2){
out.println(8);
//}else if(n==4){
// out.println(64);
}else{
int[] aa = new int[5];
for(int i = 0; i<5; i++){
if( (a-2+i) == 0) {aa[i] = n;}
else if( (a-2+i) == -1) {aa[i] = n-1;}
else if((a-2+i)>n){aa[i] = (a-2+i) %n;}
else{ aa[i] = (a-2+i);
}
System.out.println(aa[i]);
}
int[] bb = new int[5];
for(int i = 0; i<5; i++){
if( (b-2+i) == 0) {bb[i] = n;}
else if( (b-2+i) == -1) {bb[i] = n-1;}
else if((b-2+i)>n){bb[i] = (b-2+i) %n;}
else{ bb[i] = (b-2+i);
}
}
System.out.println();
int[] cc = new int[5];
for(int i = 0; i<5; i++){
if( (c-2+i) == 0) {cc[i] = n;}
else if( (c-2+i) == -1) {cc[i] = n-1;}
else if((c-2+i)>n){cc[i] = (c-2+i) %n;}
else{cc[i] = (c-2+i);
}
System.out.println(cc[i]);
}
int[] dd = new int[5];
for(int i = 0; i<5; i++){
if( (d-2+i) == 0) {dd[i] = n;}
else if( (d-2+i) == -1) {dd[i] = n-1;}
else if((d-2+i)>n){dd[i] = (d-2+i) %n;}
else{ dd[i] = (d-2+i);
}
}
int[] ee = new int[5];
for(int i = 0; i<5; i++){
if( (e-2+i) == 0) {ee[i] = n;}
else if( (e-2+i) == -1) {ee[i] = n-1;}
else if((e-2+i)>n){ee[i] = (e-2+i) %n;}
else{ ee[i] = (e-2+i);
}
}
int[] gg = new int[5];
for(int i = 0; i<5; i++){
if( (g-2+i) == 0) {gg[i] = n;}
else if( (g-2+i) == -1) {gg[i] = n-1;}
else if((g-2+i)>n){gg[i] = (g-2+i) %n;}
else{ gg[i] = (g-2+i);
}
}
for(Integer i : aa){
for(Integer j : bb){
for(Integer k : cc){
String x = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);
ar.add(x);
}
}
}
for(Integer i : dd){
for(Integer j : ee){
for(Integer k : gg){
String x = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);
ar.add(x);
}
}
}
ArrayList<String> used = new ArrayList<String>();
int count = 0;
for(String y : ar){
System.out.println(y);
if(!used.contains(y))count++;
used.add(y);
}
out.println(count);
}
out.close();
}
}