import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m = "";
int arr[]=new int[5001];
for(int i=1;i<5001;i++){
arr[i]=arr[i-1];
if(valid(i+"")){
arr[i]++;
}
}
while((m=br.readLine())!=null){
String[]str=m.split(" ");
int x=Integer.parseInt(str[0]);
int y=Integer.parseInt(str[1]);
sb.append(arr[y]-arr[x-1]).append("\n");
}
System.out.print(sb);
}
static boolean valid(String x){
int[]arr =new int[10];
for(int i=0;i<x.length();i++){
arr[x.charAt(i)-48]++;
if(arr[x.charAt(i)-48]>1)
return false;
}
return true;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m = "";
int arr[]=new int[5001];
for(int i=1;i<5001;i++){
arr[i]=arr[i-1];
if(valid(i+"")){
arr[i]++;
}
}
while((m=br.readLine())!=null){
String[]str=m.split(" ");
int x=Integer.parseInt(str[0]);
int y=Integer.parseInt(str[1]);
sb.append(arr[y]-arr[x-1]).append("\n");
}
System.out.print(sb);
}
static boolean valid(String x){
int[]arr =new int[10];
for(int i=0;i<x.length();i++){
arr[x.charAt(i)-48]++;
if(arr[x.charAt(i)-48]>1)
return false;
}
return true;
}
}
Buenas, una pregunta... Cuánto tiempo te tardó?
ReplyDeletepara solucionarlo = 20 minutos
Deletetiempo de ejecución =0.160 in java
Gracias...
Delete