A modified Kaprekar number is a positive whole number n with d digits, such that when we split its square into two pieces – a right hand piece r with d digits and a left hand piece l that contains the remaining d or d−1 digits, the sum of the pieces is equal to the original number (i.e. l + r = n).
Note: r may have leading zeros.
Here’s an explanation from Wikipedia about the ORIGINAL Kaprekar Number (spot the difference!): In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For instance, 45 is a Kaprekar number, because 45² = 2025 and 20+25 = 45.
You are given the two positive integers p and q, where p is lower than q. Write a program to determine how many Kaprekar numbers are there in the range between p and q (both inclusive) and display them all.
There will be two lines of input: p, lowest value q, highest value
Output each Kaprekar number in the given range, space-separated on a single line. If no Kaprekar numbers exist in the given range, print INVALID RANGE.
1, 9, 45, 55, and 99 are the Kaprekar Numbers in the given range.
You are given an integer N. Print the factorial of this number.
Input consists of a single integer N, where 1≤N≤100.
Print the factorial of N.
For an input of 25, you would print 15511210043330985984000000
Note: Factorials of N>20 can’t be stored even in a 64−bit long long variable. Big integers must be used for such calculations. Languages like Java, Python, Ruby etc. can handle big integers, but we need to write additional code in C/C++ to handle huge values.
We recommend solving this challenge using BigIntegers.
Manasa is out on a hike with friends. She finds a trail of stones with numbers on them. She starts following the trail and notices that two consecutive stones have a difference of either a or b. Legend has it that there is a treasure trove at the end of the trail and if Manasa can guess the value of the last stone, the treasure would be hers. Given that the number on the first stone was 0, find all the possible values for the number on the last stone.
Note: The numbers on the stones are in increasing order.
The first line contains an integer T, i.e. the number of test cases. T test cases follow; each has 3 lines. The first line contains nn (the number of stones). The second line contains a, and the third line contains b.
Space-separated list of numbers which are the possible values of the last stone in increasing order.
2 3 4
30 120 210 300
All possible series for the first test case are given below:
Hence the answer
2 3 4.
Series with different number of final steps for second test case are the following:
- 0, 10, 20, 30
- 0, 10, 20, 120
- 0, 10, 110, 120
- 0, 10, 110, 210
- 0, 100, 110, 120
- 0, 100, 110, 210
- 0, 100, 200, 210
- 0, 100, 200, 300
Hence the answer
30 120 210 300.
Original solution source