|
|
вернуться в форумjava solution (very simple) import java.util.Scanner; public class problem1197 { public static void main(String args[]) { Scanner in = new Scanner(System.in); int I = in.nextInt(); int J = in.nextInt(); if (I == 1) { System.out.println(1); return; } if (I == J) { System.out.println(I); return; } int deyer[] = new int[100001]; int idx = 0; int min = 10000; int mineded = 0; for (int i = J; i >= I; i--) { for (int j = i / 2; j >= 1; j--) { if (i % j == 0) { if (j < min) { min = j; mineded = i; if (j == 1) { System.out.println(i); return; } } break; } } } System.out.println(mineded); } } Re: java solution (very simple) Very interesting idea but I can't guess why is it always true. Can you give me some explanation on my mail please?! mamuka_sakhelashvili@yahoo.com Thanks! |
|
|