SHOW:
|
|
- or go back to the newest paste.
| 1 | import java.util.Scanner; | |
| 2 | ||
| 3 | ||
| 4 | public class A {
| |
| 5 | ||
| 6 | private static String fin = ""; | |
| 7 | ||
| 8 | public static void inicializar(String caso, String entrada){
| |
| 9 | String eso=""; | |
| 10 | String resultados[] = new String [entrada.length()-2]; | |
| 11 | int cont = 0; | |
| 12 | int sl = 3; | |
| 13 | int limite = 2; | |
| 14 | for (int j = 0 ; j < entrada.length(); j++){
| |
| 15 | char a = entrada.charAt(j); | |
| 16 | if (j<sl){
| |
| 17 | eso += a; | |
| 18 | ||
| 19 | }if(j==limite){
| |
| 20 | resultados[cont] = eso; | |
| 21 | cont++; | |
| 22 | limite++; | |
| 23 | j -= 2; | |
| 24 | eso=""; | |
| 25 | sl++; | |
| 26 | } | |
| 27 | } | |
| 28 | comparar(caso,resultados); | |
| 29 | } | |
| 30 | ||
| 31 | public static void comparar(String caso,String resul[]){
| |
| 32 | ||
| 33 | String salida = ""; | |
| 34 | String memoria[]={"TTT","TTH","THT","THH","HTT","HTH","HHT","HHH"};
| |
| 35 | int a = 0; | |
| 36 | for(int i = 0; i < memoria.length; i ++){
| |
| 37 | for(int j = 0; j < resul.length; j++){
| |
| 38 | if(memoria[i].equals(resul[j])){
| |
| 39 | a++; | |
| 40 | } | |
| 41 | } | |
| 42 | salida += a+" "; | |
| 43 | a = 0; | |
| 44 | } | |
| 45 | fin += caso + salida+"\n"; | |
| 46 | } | |
| 47 | ||
| 48 | public static void main (String []args){
| |
| 49 | ||
| 50 | Scanner leer = new Scanner(System.in); | |
| 51 | int ash; | |
| 52 | String entrada; | |
| 53 | int Casos = leer.nextInt(); | |
| 54 | ||
| 55 | String Datos[] = new String[Casos*2]; | |
| 56 | ||
| 57 | String umm[] = new String[Casos*2]; | |
| 58 | ||
| 59 | if(Casos >= 1 && Casos <= 1000){
| |
| 60 | for (int i = 1 ; i <= Casos; i++){
| |
| 61 | ash = leer.nextInt(); | |
| 62 | entrada = leer.next(); | |
| 63 | umm[i]= ash+" "; | |
| 64 | Datos[i]= entrada; | |
| 65 | inicializar(umm[i],Datos[i]); | |
| 66 | ||
| 67 | } | |
| 68 | System.out.print(fin); | |
| 69 | } | |
| 70 | } | |
| 71 | } |