Divisible Numbers
Practice
4.4 (5 votes)
Number theory
Mathematics
Gcd
Math
Problem
60% Success 816 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code
You are given \(4\) positive integers \(N\), \(a\), \(b\), and \(c\).
Your task is to calculate the total number of integers from \(1\) to \(N\) that are divisible by either \(a\), \(b\), or \(c\).
Input Format
- The first line of the input data contains the single integer \(T\) denoting the number of test cases.
- Each test case contains four integers \(N\), \(a\), \(b\) and \(c\).
Output Format:
- For each test case output the total number of intergers from \(1\) to \(N\) which are divisible by either \(a\), \(b\) or \(c\).
Constraints
- \(1 \leq T \leq 100\)
- \(1 \leq N \leq 10^9\)
- \(1 \leq a,b,c \leq N\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
7 votes
Tags:
MathematicsApprovedEasyGreatest common divisor
Points:50
13 votes
Tags:
AlgorithmsApprovedHardOpenTrees
Points:20
9 votes
Tags:
MathematicsOpenApprovedEasyGreatest common divisor
Editorial