题目
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
char[] sq1 = sc.next().toCharArray();
sc.nextLine();
char[] sq2 = sc.next().toCharArray();
Map<Character,Integer> map = new HashMap<>();
map.put('A', 0);
map.put('C', 1);
map.put('G', 2);
map.put('T', 3);
int res = 0;
for(int i=0;i<n;i++) {
if(map.get(sq1[i])+map.get(sq2[i])!=3) {
for(int j=i+1;j<n;j++) {
if((map.get(sq1[i])+map.get(sq2[j]) == 3)
&&
(map.get(sq1[j])+map.get(sq2[i]) == 3)) {
char c =sq2[i];
sq2[i] = sq2[j];
sq2[j] = c;
}
}
res++;
}
}
System.out.println(res);
sc.close();
}
}
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.nextLine();
char[] s1 = sc.next().toCharArray();
sc.nextLine();
char[] s2 = sc.next().toCharArray();
Map<Character,Integer> map = new HashMap<>();
map.put('A', 0);
map.put('C', 1);
map.put('G', 2);
map.put('T', 3);
int res = 0;
for(int i=0;i<n;i++) {
if(map.get(s1[i])+map.get(s2[i]) != 3) {
for(int j=i+1;j<n;j++) {
if(map.get(s1[i])+map.get(s2[j]) == 3
&&
map.get(s2[i])+map.get(s1[j]) == 3
) {
char t = s2[i];
s2[i] =s2[j];
s2[j] = t;
break;
}
}
res++;
}
}
System.out.println(res);
sc.close();
}
}