fork download
  1. /*package whatever //do not write package name here */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.lang.Math;
  7. class GFG {
  8. public static void main (String[] args) {
  9. Scanner sc = new Scanner(System.in);
  10. int t =sc.nextInt();
  11. System.out.println(""+t+"");
  12. while(t>0){
  13. int n1 = sc.nextInt();
  14. int n2 = sc.nextInt();
  15. // String s1=sc.nextLine();
  16. // String s2=sc.nextLine();
  17. // System.out.println(""+s1+""+s2+""+n1+""+n2+"");
  18. // System.out.println(calcs(s1,s2,n1,n2));
  19. t--;
  20. }
  21. sc.close();
  22. }
  23. static int calcs(String s1, String s2, int n1, int n2){
  24. if(n1<0 || n2<0)return 0;
  25. if(s1.charAt(n1-1)==s2.charAt(n2-1)){
  26. return 1+ calcs(s1, s2, n1-1,n2-1);
  27. } else {
  28. return Math.max(calcs(s1, s2, n1-1,n2), calcs(s1, s2, n1,n2-1));
  29. }
  30. }
  31. }
Runtime error #stdin #stdout #stderr 0.06s 2184192KB
stdin
2
6 6
ABCDGH
AEDFHR
3 2
ABC
AC
stdout
2
stderr
Exception in thread "main" java.util.InputMismatchException
	at java.util.Scanner.throwFor(Scanner.java:864)
	at java.util.Scanner.next(Scanner.java:1485)
	at java.util.Scanner.nextInt(Scanner.java:2117)
	at java.util.Scanner.nextInt(Scanner.java:2076)
	at GFG.main(Main.java:13)