PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000243. Giữ nguyên ước chung lớn nhất (Same GCDs)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Giữ nguyên ước chung lớn nhất (Same GCDs)
Same GCDs
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers , count integers such that and .
Input
One line contains positive integers in that order.
Output
Print the number of valid integers .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Example 1
Input
4 9
Output
6
Explanation
For and , and . There are coprime residues modulo .
Example 2
Input
5 10
Output
1
Explanation
For and , and . There are coprime residues modulo .
Example 3
Input
42 9999999967
Output
9999999966
Explanation
For and , and . There are coprime residues modulo .