回答編集履歴
1
重複した要素と素数への対応の変更
test
CHANGED
@@ -6,60 +6,68 @@
|
|
6
6
|
|
7
7
|
```java
|
8
8
|
|
9
|
-
i
|
9
|
+
int flag=0;
|
10
10
|
|
11
|
-
list
|
11
|
+
Collections.sort(index, (i1, i2) -> num.get(i1) - num.get(i2));
|
12
12
|
|
13
|
-
List<Integer> index = new ArrayList(num.size());
|
14
13
|
|
15
|
-
for (int i = 0; i < num.size(); i++) {
|
16
14
|
|
17
|
-
inde
|
15
|
+
List<Integer> oldNum = new ArrayList<>(num);
|
18
16
|
|
19
|
-
|
17
|
+
for (int i = 0; i < index.size(); i++) {
|
20
18
|
|
21
|
-
|
19
|
+
num.set(i, oldNum.get(index.get(i)));
|
22
20
|
|
23
|
-
|
21
|
+
}
|
24
22
|
|
25
|
-
|
23
|
+
List<String> oldFizz = new ArrayList<>(fizz);
|
26
24
|
|
27
|
-
|
25
|
+
for (int i = 0; i < index.size(); i++) {
|
28
26
|
|
29
|
-
|
27
|
+
fizz.set(i, oldFizz.get(index.get(i)));
|
30
28
|
|
31
|
-
|
29
|
+
}
|
32
30
|
|
33
|
-
|
31
|
+
int m = list.get(list.size()-1);
|
34
32
|
|
35
|
-
|
33
|
+
for(int i=0;i<num.size();i++) {
|
36
34
|
|
37
|
-
|
35
|
+
if(m%num.get(i)==0) {
|
38
36
|
|
39
|
-
|
37
|
+
System.out.print(fizz.get(i));
|
40
38
|
|
41
|
-
|
39
|
+
}else{
|
42
40
|
|
43
|
-
|
41
|
+
flag += 1;
|
44
42
|
|
45
|
-
|
43
|
+
}
|
46
44
|
|
47
|
-
|
45
|
+
}if(flag==num.size()&&m>2){
|
48
46
|
|
49
|
-
|
47
|
+
for(int i=0;i<num.size();i++) {
|
50
48
|
|
51
|
-
|
49
|
+
for(i = 2; i < m; i++){
|
52
50
|
|
53
|
-
|
51
|
+
if(m % i == 0) {
|
54
52
|
|
55
|
-
|
53
|
+
System.out.println(m);
|
56
54
|
|
57
|
-
|
55
|
+
}else{
|
58
56
|
|
59
|
-
|
57
|
+
System.out.println("prime");
|
60
58
|
|
61
|
-
}
|
59
|
+
}return;
|
62
60
|
|
63
|
-
}
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
}else if(flag==num.size()&&m<=2){
|
66
|
+
|
67
|
+
System.out.println(m);
|
68
|
+
|
69
|
+
return;
|
70
|
+
|
71
|
+
}
|
64
72
|
|
65
73
|
```
|