-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdicecup.java
99 lines (68 loc) · 1.42 KB
/
dicecup.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
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
import java.util.ArrayList;
import java.util.Scanner;
public class dicecup {
public static void printMatrix(int[][] a){
for(int r = 0; r < a.length; r++)
{
for(int c = 0; c < a[0].length; c++)
{
System.out.print(a[r][c] + " ");
}
System.out.println();
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int d1 = scan.nextInt();
int d2 = scan.nextInt();
int[][] sum = new int[d1][d2];
for(int r = 0; r < d1; r++)
{
int i=2;
for(int c = 0; c < d2; c++)
{
sum[r][c] = r + i;
i++;
}
}
int[] prob = new int[d1+d2+1];
for(int i=0; i < prob.length; i++)
{
prob[i] = 0;
}
for(int r = 0; r < sum.length; r++)
{
for(int c = 0; c < sum[0].length; c++)
{
prob[sum[r][c]]++;
}
}
/**for(int i=0; i < prob.length; i++)
{
System.out.print(prob[i] + " ");
}*/
ArrayList<Integer> res = new ArrayList<>();
int ind = 0;
for(int i=1; i < prob.length-1; i++)
{
if(prob[i] >= prob[i+1])
{
ind = i;
break;
}
}
//System.out.println(ind);
for(int i=0; i < prob.length; i++)
{
if(prob[i] == prob[ind])
{
res.add(i);
}
}
for(int i=0; i < res.size(); i++)
{
System.out.println(res.get(i));
}
scan.close();
}
}