Algorithm


Problem link- https://www.spoj.com/problems/EIGHTS/

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.

Input

The first line of the input contains an integer t, the number of test cases. t test cases follow.

Each test case consists of a single line containing a single integer k (1 <= k <= 2000000000000).

Output

For each test case, output a single integer which denotes the kth number whose cube ends in 888. The result will be less than 263.

Example

Input:
1
1

Output:
192

 

Code Examples

#1 Code Example with Java Programming

Code - Java Programming

import java.util.*;
import java.lang.*;

class Main
{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		
		long t = s.nextLong();
		
		while(t > 0){
			long k =s.nextLong();
			long res = 250*(k-1) + 192;
			System.out.println(res);
			t--;
		}
	}
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1 1

Output

x
+
cmd
192

#2 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>

using  namespace std;

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
    int T,m;
    long long k;
    
    scanf("%d",&T);
    
    for(int tc=1;tc<=T;tc++){
        scanf("%lld",&k);
        
        k--;
        m=k&3;
        k/=4;
        
        
        if(k>0) printf("%lld",k);
        
        if(m==0) printf("192\n");
        else if(m==1) printf("442\n");
        else if(m==2) printf("692\n");
        else printf("942\n");
    }
    
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
1 1

Output

x
+
cmd
192
Advertisements

Demonstration


SPOJ Solution-Triple Fat Ladies-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python