Coprime Integers
시간 제한: 2000ms메모리 제한: 512MB출처: ICPC Mid-Central Regional 2018BOJ 16409
문제
Given intervals [a, b] and [c, d], count the number of ordered pairs of co-prime integers (x, y) such that a ≤ x ≤ b and c ≤ y ≤ d. Coprime integers have no common factor greater than 1.
입력
The input consists of a single line of four space-separated integers a, b, c, and d. These integers satisfy the bounds (1 ≤ a ≤ b ≤ 107, 1 ≤ c ≤ d ≤ 107).
출력
Print a single integer: the number of coprime pairs (x, y) with a ≤ x ≤ b, c ≤ y ≤ d.
예제
예제 1
입력
1 5 1 5
출력
19
예제 2
입력
12 12 1 12
출력
4
예제 3
입력
1 100 1 100
출력
6087
코드를 제출하려면 로그인하세요.