EIGHTS – Triple Fat Ladies


Pattern Matchers have been designed for various sorts of patterns. Mr. HKP likes to observe patterns in numbers. After completing his extensive research on the squares of numbers, he has moved on to cubes. Now he wants to know all numbers whose cube ends in 888.

Given a number k, help Mr. HKP find the kth number (indexed from 1) whose cube ends in 888.

Read full question here

Hint: Well there is a hidden pattern in the numbers whose cube ends in 888, use google spreadsheet to find it out 😀


using namespace std;
typedef long long unsigned lli;
int main(){
	int t;
	cin >> t;
		lli k;
		cin >> k;
		cout << 192 + (k-1)*250 << '\n';
	return 0;

Explanation: First of all only those number which ends with 2 can have 888 as their last 3 digit. Also first number is 192, now if you make a table of numbers having 888 at the end of their cubes, you will figure out that they are separated by 250.

Share This:

Next Post

Previous Post

© 2017 Kodemonk

Theme by Anders Norén