Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.math.*;
- import java.security.*;
- import java.text.*;
- import java.util.*;
- import java.util.concurrent.*;
- import java.util.regex.*;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int m=in.nextInt();
- for (int n = 1; n <=m ; n++) {
- int x=in.nextInt();
- String[] word=new String[x];
- double[] time=new double[x];
- int k=-1;
- for (int i = 0; i <x; i++) {
- String w=in.next();
- int count=0,pos=0;
- for (int j = 0; j < x; j++) {
- if(w.equalsIgnoreCase(word[j])){
- count++;
- pos=j;
- break;
- }
- }
- if(count==0){
- double sum=0.2;
- for (int p = 1; p <w.length() ; p++) {
- char c=w.charAt(p);
- if(c=='d'||c=='f'){
- char cc=w.charAt(p-1);
- if(cc=='d'|| cc=='f'){
- sum=sum+0.4;
- }else{
- sum=sum+0.2;
- }
- }
- else if(c=='j'|| c=='k'){
- char cp=w.charAt(p-1);
- if(cp=='j'|| cp=='k'){
- sum=sum+0.4;
- }else{
- sum=sum+0.2;
- }
- }
- }
- k++;
- word[k]=w;
- time[k]=sum;
- }
- else if(count!=0){
- double v=time[pos];
- v=v/2;
- k++;
- word[k]=w;
- time[k]=v;
- }
- }
- double total=0;
- for (int i = 0; i <x ; i++) {
- if(time[i]!=0){
- total=total+time[i];
- }
- }
- total=total*10;
- int Atlast=(int)total;
- System.out.println(Atlast);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement