public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    OutputWriter out = new OutputWriter(System.out);
    int tc = in.nextInt();
    while (tc-- > 0) {
      String a = in.nextString();
      String b = in.nextString();
      int[][] dp = new int[2][b.length() + 1];
      dp[1][0] = 1;
      for (int i = 0; i <= b.length(); i++) {
        dp[0][i] = i;
      }

      for (int i = 1, r = a.length(); i <= r; i++) {
        dp[i % 2][0] = i;
        for (int j = 1, c = b.length(); j <= c; j++) {
          if (a.charAt(i - 1) == b.charAt(j - 1)) {
            dp[i % 2][j] = dp[(i - 1) % 2][j - 1];
          } else {
            dp[i % 2][j] = 1 + min(dp[(i - 1) % 2][j], dp[(i - 1) % 2][j - 1], dp[i % 2][j - 1]);
          }
        }
      }

      out.println(dp[a.length() % 2][b.length()]);
    }

    out.flush();
    out.close();
  }
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    OutputWriter out = new OutputWriter(System.out);
    Solver solver = new Solver(in, out);

    solver.solve();
    in.close();
    out.flush();
    out.close();
  }
  public static void main(String[] args) {
    in = new InputReader(System.in);
    out = new OutputWriter(System.out);

    solve();

    out.flush();

    in.close();
    out.close();
  }
Exemple #4
0
    public static void main(String[] argv) throws IOException
    {
        Task t;
        boolean home = argv.length > 0 && argv[0].equals("test");
        InputStream inputStream;
        OutputStream outputStream;
        if (home) {
            inputStream = new FileInputStream(Task.filename + ".in");
            outputStream = new FileOutputStream(Task.filename + ".out");
        } else {
            switch (Task.read) {
                case 0:
                    inputStream = new FileInputStream(Task.filename + ".in");
                    outputStream = new FileOutputStream(Task.filename + ".out");
                    break;
                case 1:
                    inputStream = new FileInputStream("input.txt");
                    outputStream = new FileOutputStream("output.txt");
                    break;
                default:
                    inputStream = System.in;
                    outputStream = System.out;
                    break;

            }

        }
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream, home);


        if (home)
            do {
                long time = System.currentTimeMillis();
                t = new Task();
                t.in = in;
                t.out = out;
                t.run();

                out.writeln();
                out.writeln("=====Time:" + (System.currentTimeMillis() - time));
                out.flush();
            } while (in.toNextTest());
        else {
            t = new Task();
            t.in = in;
            t.out = out;
            t.run();
        }

        out.close();

    }
Exemple #5
0
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    OutputWriter out = new OutputWriter(System.out);
    int tc = in.nextInt();
    while (tc-- > 0) {
      int n = in.nextInt();
      out.println(countTri(n));
    }

    out.flush();
    out.close();
  }
Exemple #6
0
 public static void main(String[] args) throws IOException {
   // InputStream inputStream = new FileInputStream("replaceme.in");
   // OutputStream outputStream = new FileOutputStream("replaceme.out");
   /////////////////////////////////////////////////////////////////////
   InputStream inputStream = System.in;
   OutputStream outputStream = System.out;
   InputReader in = new InputReader(inputStream);
   OutputWriter out = new OutputWriter(outputStream);
   Task solver = new Task();
   solver.solve(1, in, out);
   out.close();
   System.exit(0);
 }
Exemple #7
0
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    OutputWriter out = new OutputWriter(System.out);
    while (true) {
      int n = in.nextInt();
      if (n == 0) break;
      int c = 0;
      while (n > 1) {
        n /= 2;
        c++;
      }

      out.println(c);
    }
    out.flush();
    out.close();
  }