// https://www.hackerrank.com/challenges/prng-sequence-guessing
import java.util.Random;
import java.util.Scanner;

public class prng {
 public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  int n = in.nextInt();
  for (int i = 0; i < n; i++) {   
   int a = in.nextInt();
   int b = in.nextInt();
   int[] prns = new int[10];
   for (int j = 0; j < 10; j++) {
    prns[j] = in.nextInt();
   }
   for (int s = a; s <= b; s++) {
    Random r = new Random();
    r.setSeed(s);
    boolean matched = true;
    for (int j = 0; j < 10; j++) {
     int c = r.nextInt(1000);     
     if (c != prns[j]) {
      matched = false;
      break;
     }
    }
    if (matched) {
     System.out.print(s);
     for (int j = 0; j < 10; j++) {
      int c = r.nextInt(1000);
      System.out.print(" " + c);
     }
     System.out.println();
     break;
    }
   }
  }
  in.close();
 }
}

신고
Posted by steloflute


Generate bitcoin for me

What's this?