Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the sum of all integers from 1 to 50 inclusive that are coprime to 50?
- A. 501
- B. 775
- C. 625
- D. 500
Correct answer: D. 500
Coprime to 50 = 2 * 5^2 means odd and not divisible by 5. The odd numbers total 625 and the odd multiples of 5 (5, 15, 25, 35, 45) total 125, leaving 500.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Let L be the length of the longest common subsequence of "ABCBDAB" and "BDCABA". How many different index-selections in "ABCBDAB" give a…
- What is the length of the longest common subsequence of "dbacabb" and its cyclic rotation by one position (the string with its first…
- Using only insertions and deletions (no substitutions), what is the minimum number of operations needed to turn "heat" into "hit"?
- How many permutations of the numbers 1 to 6 have a longest increasing subsequence of length exactly 3?
- How many permutations of 1, 2, 3, 4, 5 have EXACTLY 4 inversions? An inversion is a pair of positions i < j with p[i] > p[j].
- Piles of stones [3, 5, 1, 2, 6] are in a row. Each move merges two ADJACENT piles into one, at a cost equal to their combined number of…