Description
This problem is a programming version of Problem 45 from projecteuler.net
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle
Pentagonal
Hexagonal Tn = n(n + 1)/2
Pn = n(3n − 1)/2
Hn = n(2n − 1) 1,3,6,10,15,⋯
1,5,12,22,35,⋯
1,6,15,28,45,⋯
It can be verified that T285 = P165 = H143 = 40755
For this challene you are given N, a, b, where a < b and a,b ∈ {3,5,6}
where 3 represents triangular numbers, 5 represents pentagonal numbers and 6 is hexagonal. It can be observed that all hexagonal numbers are triangular numbers so we’ll handle only 2 kinds of queries as N 3 5, find all numbers below N which are Triangular number as well as Pentagonal
N 5 6, find all numbers below N which are Pentagonal number as well as Hexagonal
Input Format
Input contains three integers N a b
Output Format
Print the answer corresponding to the test case. Print numbers in ascending oder.
Constraints
2 ≤ N ≤ 2 × 1014
a,b ∈ {3,5,6}
a < b
Sample Input #00
Sample Output #00
Sample Input #01
Sample Output #01




Reviews
There are no reviews yet.