import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(br.readLine());
if (a<=0) throw new Exception();
int b = Integer.parseInt(br.readLine());
if (a<=0) throw new Exception();
br.close();
while (a != 0 && b != 0) {
if (a > b) {
a = a % b;
} else if (b > a) {
b = b % a;
}
}
System.out.println(a + b);
}
}
Yury Ezhov
37 уровень
Подскажите почему вылетает сообщение Программа работала слишком долго и была закрыта В IDE все отлично работает
Решен
Комментарии (2)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
Сергеев ВикторMaster
5 сентября 2017, 17:46
попробуйте 177 и 177
0
Yury Ezhov
5 сентября 2017, 17:56
Спасибо, не заметил, все прошло
0