Odd divisors
Practice
2.8 (27 votes)
Basic programming
Problem
87% Success 9753 Attempts 20 Points 5s Time Limit 256MB Memory 1024 KB Max Code
You are given a positive integer \(N\).\(f(N)\) is the greatest odd divisor of \(N\).
Find the sum \((f(1) + f(2) + ... + f(N))\%M\).
Input format
- The first line of the input contains a single integer \(T\) \((T ≤ 100)\) denoting the number of test cases. The description of \(T\) test cases follows.
- The first line of each test case contains two integers \(N\) and \(M\) \((N ≤ 10^{18},\ M≤10^9)\).
Output format
For each value of \(N\), print the value of \((f(1) + f(2) + ... + f(N))\%M\) in a separate line.
Explanation
-
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:20
8 votes
Tags:
Ad-HocApprovedEasyPriority queueapproved
Points:20
24 votes
Tags:
Basic ProgrammingEasyMath
Points:20
72 votes
Tags:
ApprovedBasic ProgrammingEasy
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor