Roy and Rangoli
Practice
4.2 (10 votes)
Approved
Implementation
Math
Medium
Open
Primality test
Problem
93% Success 4641 Attempts 30 Points 3s Time Limit 256MB Memory 50 KB Max Code
Its Diwali time and little Roy thought of an interesting design for Rangoli. He created an N x N grid. Roy fills some of the cells of grid with red color.
Cell located at ith row and jth column is colored if i+j is prime. Consider Zero-based numbering of grid. (See Sample Test Case Explanation for clarification)
Roy wants to know how many cells he will have to color given the size of grid N.
Input:
One integer indicating size of grid N
Output:
Print a single integer, number of cells Roy will have to color. Since answer can be very large output it modulo 1000000007
Constraints:
1<= N <=1000000
Sample Test Case Explanation:
Submissions
Please login to view your submissions
Similar Problems
Points:30
18 votes
Tags:
Hash MapsMathMediumMeet In the MiddleNumber TheoryPrimality testPrime Factorization
Points:30
3 votes
Tags:
MathMediumNumber TheoryPrimality test
Points:30
5 votes
Tags:
ApprovedMathMediumOpen
Editorial