[Offer收割]编程练习赛7 register

Ended

Participants:506

Verdict:Accepted
Score:100 / 100
Submitted:2016-08-28 13:54:04

Lang:Java

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] s = new String[n];
        for(int i=0i<ni++){
            s[i= in.next();
        }
        
        int count = 0;
        Set<String> set = new HashSet<String>();
        for(String str : s){
            char[] ch = str.toCharArray();
            int len = ch.length;
            char[] newch = new char[len];
            for(int i=0i<leni++){
                newch[i= ch[len-1-i];
            }
            String newstring = new String(newch);
            if(set.contains(newstring)) count++;
            else set.add(str);
        }
        
        System.out.println(count);
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX