fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. Random random = new Random();
  9. int roll = random.nextInt(91);
  10. int num1 = (int) (Math.sqrt(8*roll + 1) - 1)/2;
  11. int num2 = roll - num1*(num1+1)/2;
  12. System.out.println(String.format("roll: %d, num1: %d, num2: %d", roll, num1, num2));
  13. }
  14. }
Success #stdin #stdout 0.07s 381184KB
stdin
Standard input is empty
stdout
roll: 78, num1: 12, num2: 0