import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String t1 = scanner.next(); String t2 = scanner.next(); String[] split1 = t1.split(":"); String[] split2 = t2.split(":"); long time1 = Integer.parseInt(split1[0]) * 2500 + Integer.parseInt(split1[1]); long time2 = Integer.parseInt(split2[0]) * 2500 + Integer.parseInt(split2[1]); int count=0; long temp = time1; for (long i = time1; i <= time2; i++) { if (i%2500>=59) { i = i - 59 + 2500; } if (sushu(i)) { count++; } } System.out.println(count); } } public static boolean sushu(long number) { boolean flag = true; for (int i = 2; i <= Math.sqrt(number); i++) { if (number % i == 0) { flag = false; break; } } return flag; } } |
Double click to view unformatted code.