import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class Main { static long max = 987654321;//comm P2t : je mult par 10 apres, sinon ca depasse l'int :) static long min = 1023456789; public static void main(String[] args)throws IOException { max *= 10; long time=System.currentTimeMillis(); affiche(); time -= System.currentTimeMillis(); System.out.println("temps ecoulé: "+ (-time)+"ms"); } public static long check_all(int x, long min, long max){ for(long i=min;i<max;i++){ //des que trouver renvoyer le nombre. if(check(i*x)) return i*x; } //si rien trouvé return -1 return -1; } static int k; public static boolean check(long x){ boolean tab[]=new boolean[10]; for(int j=0;j<10;j++){ k=(int)(x%10); if(tab[k]) return false; tab[k]=true; x/=10; } return true; } public static void affiche() throws IOException { BufferedReader lecteurAvecBuffer = null; FileWriter writer = null; String ligne; try { lecteurAvecBuffer = new BufferedReader(new FileReader("//home//audrey//Bureau//listePremier")); writer = new FileWriter("//home//audrey//Bureau//fichier.txt", true); } catch(FileNotFoundException exc) { System.out.println("Erreur d'ouverture"); } while ((ligne = lecteurAvecBuffer.readLine()) != null){ int x= Integer.parseInt(ligne); //System.out.println(x+": "+check_all(x,min/x,max/x)); String texte = x+": "+check_all(x,min/x,max/x)+"\n"; writer.write(texte,0,texte.length()); } lecteurAvecBuffer.close(); writer.close(); } }