fork download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6. import java.util.StringTokenizer;
  7.  
  8. class Duh{
  9. public static void main(String []args) throws IOException{
  10. Scanner scan = new Scanner(System.in);
  11. int test_cases = scan.nextInt();
  12. ArrayList<Long> list = new ArrayList<>();
  13. long count=0;
  14. for(int m =0;m<test_cases;m++){
  15. int num_of_games_played_by_elephant = scan.nextInt();
  16.  
  17. for(int i =0;i<num_of_games_played_by_elephant;i++){
  18. String inputssss = bf.readLine();
  19. StringTokenizer st = new StringTokenizer(inputssss," ");
  20. int coins_face = Integer.parseInt(st.nextToken());
  21. long no_of_coins = Long.parseLong(st.nextToken());
  22. int guess = Integer.parseInt(st.nextToken());
  23. if(no_of_coins%2==0){
  24. if(guess==1 || guess ==2){
  25. count =no_of_coins/2;
  26. }
  27. }
  28. else if(no_of_coins%2==1){
  29. if(guess!=coins_face){
  30. count = no_of_coins/2;
  31. }
  32. else {
  33.  
  34. count = (no_of_coins / 2) + 1;
  35. }
  36. }
  37. list.add(count);
  38. count=0;
  39. }
  40.  
  41. }
  42. for(int m = 0; m<list.toArray().length;m++){
  43. System.out.println(list.get(m));
  44. }
  45. }
  46. }
  47.  
Runtime error #stdin #stdout #stderr 0.06s 4386816KB
stdin
1
2
1 5 1
1 5 2
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NullPointerException
	at java.util.StringTokenizer.<init>(StringTokenizer.java:199)
	at java.util.StringTokenizer.<init>(StringTokenizer.java:221)
	at Duh.main(Main.java:20)