Even Odd
Practice
3.7 (3 votes)
Ad Hoc
Easy Medium
Math
Problem
41% Success 10975 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
We have the following matrix
1 0 0 0 0 0 ...
2 2 0 0 0 0 ...
3 3 3 0 0 0 ...
4 4 4 4 0 0 ...
5 5 5 5 5 0 ...
6 6 6 6 6 6 ...
and so on ...
The matrix is created as follows, first row contains one 1 and rest \(0's\), second row contains 2 twos and rest zeros, third row contains 3 threes and so on.
Given R and C, calculate the count of even and odd numbers in sub matrix \([R,C]\) .
0 is neither odd nor even and 1 based indexing is used i.e. matrix \([1,1]=1\)
Input:
First line contains number of test cases T.Each test case contains two integers R and C.
Output
For each test case print count of even and odd numbers in sub matrix \([R,C]\).
Constraints:
1<=T<= \(100000 \)
1<=R<= \(100000 \)
1<=C<=\(100000 \)
Submissions
Please login to view your submissions
Similar Problems
Points:30
39 votes
Tags:
MathematicsOpenApprovedEasy-MediumMathamatics
Points:30
Tags:
Easy-Medium
Points:30
463 votes
Tags:
Ad-HocEasy-MediumMathamatics
Editorial