Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Solution {
- public static void main(String args[]){
- long a = 0;
- Random rand = new Random();
- for(int i = 0; i < 10000; i++){
- int[] arr = new int[4];
- arr[0] = rand.nextInt(6) + 1;
- arr[1] = rand.nextInt(6) + 1;
- arr[2] = rand.nextInt(6) + 1;
- arr[3] = rand.nextInt(6) + 1;
- Arrays.sort(arr);
- while(arr[1] < 3){
- arr[1] = rand.nextInt(6) + 1;
- }
- while(arr[2] < 3){
- arr[2] = rand.nextInt(6) + 1;
- }
- while(arr[3] < 3){
- arr[3] = rand.nextInt(6) + 1;
- }
- a += arr[1] + arr[2] + arr[3];
- }
- System.out.println(a/10000.0);
- long b = 0;
- for(int i = 0; i < 10000; i++){
- int[] arr = new int[4];
- arr[0] = rand.nextInt(6) + 1;
- arr[1] = rand.nextInt(6) + 1;
- arr[2] = rand.nextInt(6) + 1;
- arr[3] = rand.nextInt(6) + 1;
- while(arr[0] < 3){
- arr[0] = rand.nextInt(6) + 1;
- }
- while(arr[1] < 3){
- arr[1] = rand.nextInt(6) + 1;
- }
- while(arr[2] < 3){
- arr[2] = rand.nextInt(6) + 1;
- }
- while(arr[3] < 3){
- arr[3] = rand.nextInt(6) + 1;
- }
- Arrays.sort(arr);
- b += arr[1] + arr[2] + arr[3];
- }
- System.out.println(b/10000.0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement