Code Experts 2.0 was a programming competition for school children, organized by IEEE student branch of University of Moratuwa in 2014 for the 2nd consecutive time. It is a 6 hour coding challenge, where school students are free to form a group of three. At that time I was a member of problem creation panel and we were supposed to add creative and unique questions to the competition. The question give below called “Happy and Sad Numbers” was added by me.
Question
A number which sum of squares of
individual digits eventually equal to 1 is called a Happy Number otherwise
called a Sad Number.
You
have to count the number of sad numbers with tail size k Ñ” Z+ in
given range X = [a, b], where a, b Ñ” Z+ and a < b < 109
Input Format
a space b space k
Sample Input (10 1000 is interval(closed) and 7 is tail size)
10 1000 7
Sample Output
83
More Sample input and outputs