-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path404 El Telefono De Meucci
39 lines (36 loc) · 1.06 KB
/
404 El Telefono De Meucci
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
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
public class ElTelefonoDeMeucci {
static int tot=0;
static String fr="";
static String[] set1 = {"I","II","III","IV","V","VI","VII","VIII","IX","X"};
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
while(t.hasNext()){
tot = 0;
fr=t.next();
if(!fr.contains("I")&&!fr.contains("V"))
tot++;
else
buscar(fr);
System.out.println(tot);
}
}
private static void buscar(String f) {
for(int i=1;i<5&&i<=f.length();i++){
boolean encontrado=false;
for(int j=0;j<10;j++){
if(f.substring(0,i).equals(set1[j]))
encontrado=true;
}
if(encontrado){
String res=f.substring(i,f.length());
if(res.length()>0)
buscar(res);
else if(res.length()==0){
tot++;
return;
}
}
}
}
}