Suhana and Equation
CodeChefOpen on judge ↗
Suhana is studying following equation : f(N) = 00 + 11 + 22 + 33 + 44 + ... + NN Can you solve f(N) % M before Suhana does? Input First line contains T, number of test cases. First line of each test case contains N and M. Output Output the required answer in new line. Constraints - 1 ≤ T ≤ 100 - 1 ≤ N ≤ 10^9 - 1 ≤ M ≤ 10^3 Example Input: 4 1 9 2 29 3 93 40 993 Output: 2 6 33 90
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start