Coprime
Time limit1sMemory limit512 MB
Given n and k up to 1e14, sum all integers in [1, nk] that are coprime with n, using inclusion-exclusion over n's prime factors and periodicity mod n.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
You are given two integers and . Find the sum of all positive integers less than or equal to and coprime with .
Input
The first and only line of the input contains two integers and .
Output
Print the answer.
Constraints
- All values in input are integers.