Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.util.concurrent.TimeUnit;
- import java.io.*;
- public class test31 {
- public static void main(String[] s) throws IOException {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- for (int w=0; w<n; w++){
- int k = in.nextInt();
- String a = in.next();
- String b = in.next();
- int c = 0; //the amount of numbers were not changed
- for (int i = 0; i < Math.min(a.length(), b.length()); i++){
- if (a.charAt(i) == b.charAt(i)){
- c++;
- }else{
- break;
- }
- }
- int r = (Math.min(a.length(), b.length()) - c) * 2 +
- (Math.max(a.length(), b.length())-Math.min(a.length(), b.length())); //min amount of changes to get the result
- if (k-r >= 0 && (k-r)%2 == 0){
- System.out.println("Yes");
- }else{
- System.out.println("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement