lets-begin

February Easy Challenge 2015  is underway. Hackerearth welcomes you all and hope that all you awesome coders have a great time. So without wasting much of the time let's begin the contest.  

Prime Numbers have always been one of the favourite topics for problem setters. For more information on them you can use see this link http://en.wikipedia.org/wiki/Prime_number .  

Aishwarya is a mathematics student at the Department of Mathematics and Computing, California. Her teacher recently gave her an intriguing assignment with only a single question. The question was to find out the minimum number of single digit prime numbers which when summed equals a given number X. 

Input:
The first line contains T denoting the number of test cases. Each of the next T lines contains a single integer X.  

Output:
Print the minimum number required.  If it is not possible to obtain X using single digit prime numbers, output -1.  

Constraints:
1 ≤ T ≤ 100
1 ≤ X ≤ 10^6  

SAMPLE INPUT
4
7
10
14
11

SAMPLE OUTPUT
1
2
2
3

Explanation

10 can be represented as 7 + 3.

14 can be represented as 7+7

11 can be represented as 5+3+3.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
import sys 
sys.setrecursionlimit(1000000)
def few(n):
	#print n
	if n<2:
		return 0
	#if n==0:
	 #   return 1
	if dp[n]!=-1:
		 return dp[n]
	dp[n]=min(few(n-2)+1,few(n-3)+1,few(n-5)+1,few(n-7)+1)
	return dp[n]
t=eval(input())
dp=[-1]*(10**6+1)
while t!=0:
	n=eval(input())
	#dp=[-1]*(n+1)
	dp[2]=1
	dp[3]=1
	dp[4]=2
	dp[5]=1
	dp[6]=2
	dp[7]=1
	dp[8]=2
	if few(n)!=-1 and few(n)!=0:
	   print(few(n))
	else:
		print(-1)
	t-=1       


T = eval(input())

for i in range(T):
	number = eval(input())
	if number == 1:
		print(-1)
		continue
	p = number / 7
	r = number % 7
	
	if r == 1:
		p += 1
	if r == 2:
		p += 1
	if r == 3:
		p += 1
	if r == 4:
		p += 2
	if r == 5:
		p += 1
	if r == 6:
		p += 2
	print(p)


#!/usr/bin/env python

primes = [2, 3, 5, 7]
calc_p = {4:[2, 2], 6:[3, 3]}

def find_primes(X, num):

	output = []

	if X % num == 0:
		output.extend([num]*(X//num))
		return output

	elif X % num in primes:
		output.extend([num]*(X//num) + [X % num])

	elif X % num in calc_p:
		output.extend([num]*(X//num) + calc_p[X%num])

	elif X % num == 1:
		new_X = X - (7 * ((X // 7) - 1) )
		output.extend([num]*(X//num - 1) + find_primes( new_X, primes[primes.index(num) -1] )  )

	return output

tc = int(input())

for i in range(tc):

	X = int(input())

	if X == 1:
		print(-1)
		
	else:
		output = find_primes(X, primes[-1])
		print(len(output))


testCase = int(input())
while(testCase>0):
	x = int(input())
	if(x==1):
		print((-1))
	else:
		counter=0
		while(x>0):
			counter+=1
			if(x>=7):
				x-=7
			elif(x>=5):
				x-=5
			elif(x>=3):
				x-=3
			else:
				x-=2
		print(counter)
	testCase-=1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#t=inprint 'Hello World!'

		
		

		
for i in range(eval(input())):
	x=eval(input())
	if(x==1):
		print("-1")
		continue
	p=x/7
	r=x%7
	if(r==1 or r==2 or r==3 or r==5):
		p+=1
	if(r==4 or r==6):
		p+=2
	print(p)		



f = lambda :input()

primes = [2,3,5,7]
high = 99999999
min_primes = [high] * 1000001

for i in primes:
	min_primes[i] = 1

t = int(f())

setup = True
prime_sums = [2, 3, 5, 7]

for i in range(1, 1000001):
	if min_primes[i] != high:
		for j in primes:
			if i+j < 1000000:
				min_primes[i+j] = min(min_primes[i+j], min_primes[i]+1)
								   
for i in range(t):
	case = int(f())
	if min_primes[case] != high:
		print(min_primes[case])
	else:
		print(-1)


t=int(input())
while t:
	x=int(input())
	ans=0
	if x==1:
		print(-1)
	elif x%7==0:
		print(x/7)
	else:
		ans=int(x/7)
		if x%7==6:
			print(ans+2)
		elif x%7==5:
			print(ans+1)
		elif x%7==4:
			print(ans+2)
		elif x%7==3:
			print(ans+1)
		elif x%7==2:
			print(ans+1)
		else:
			print(ans+1)
	t=t-1
		


INF = 1000010
DP = {} 
l = [2,3,5,7]
def getMin(X):
	if X == 0: 
		return 0
	
	if X in list(DP.keys()):
		return DP[X]
	mini = INF
	for p in l:
		if X - p >= 0:
			mini = min (mini, getMin(X-p)+1)
	DP[X] = mini
	return mini
mini_table = {}
for i in range(1000010):
	mini_table[i] = INF
for p in l:
	mini_table[p] = 1
for i in range(2,1000001):
	for p in l:
		mini_table[i+p] = min (mini_table[i+p], mini_table[i]+1)
T = int(input())
for i in range(T):
	X = int(input())
	#ans = getMin(X)
	ans = mini_table[X]
	if ans >= INF:
		ans = -1
	print(ans)
	
	


def func(n):
	ans=0
	if(n<2):
		return -1
	temp=n
	while(temp>6):
		temp-=7
		ans+=1
#		print "b"
	while(temp>4):
		temp-=5
		ans+=1
#		print "c"
	while(temp>2):
		temp-=3
		ans+=1
#		print "d"
	while(temp>1):
		temp-=2
		ans+=1
#	print temp,"n"
	if temp==1:
		ans+=1
	return ans
t=int(input())
i=0
while i<t:
	n=int(input())
	ans=func(n)
	print(ans)
	i+=1


T=int(input())
DP=[-1]*1000005
DP[2],DP[5],DP[3],DP[7]=1,1,1,1

while T>0:
	X=int(input())

	if DP[X]!=-1:
		print(DP[X])
	elif X<=7:
		print(DP[X])

	else:
		for i in range(8,X+1):
			if DP[i]!=-1:
				continue
			else:
				minNum=float('inf')
				minSet=False
				if DP[i-3]!=-1:
					minSet=True
					minNum=min(minNum,1+DP[i-3])
				if DP[i-5]!=-1:
					minSet=True
					minNum=min(minNum,1+DP[i-5])
				if DP[i-7]!=-1:
					minSet=True
					minNum=min(minNum,1+DP[i-7])
				if DP[i-2]!=-1:
					minSet=True
					minNum=min(minNum,1+DP[i-2])

				if minSet:
					DP[i]=minNum
				else:
					DP[i]=-1

		print(DP[X])

	T-=1






l=[-1]*(10**6+1)
prime = [7,5,3,2]
l[1]=-1
l[4]=2
l[6]=2
l[2]=l[3]=l[5]=l[7]=1

for i in range(8,10**6+1):
	for num in prime:
		if i-num>=0:
			if l[i-num]!=-1:
				l[i]=1+l[i-num]
				break
			

t=eval(input())
for i in range(t):
	n=eval(input())
	print(l[n])
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#t=inprint 'Hello World!'

		
		
n=eval(input())
for i in range(n):
	x=eval(input())
	if(x==1):
		print("-1")
		continue
	p=x/7
	r=x%7
	if(r==1):
		p=p+1
	if(r==2):
		p=p+1
	if(r==3):
		p=p+1
	if(r==5):
		p=p+1
	if(r==4):
		p=p+2
	if(r==6):
		p=p+2
	print(p)



pre_process=[0]*100000
l=[2,3,5,7]
pre_process[2]=1
pre_process[3]=1;
pre_process[4]=2;
pre_process[5]=1;
pre_process[6]=2;
pre_process[7]=1;
pre_process[8]=2;

for i in range(9,100000):
	temp_list=[0]*4
	for j in range(4):
		temp_list[j]=i-l[j]
		temp_list[j]=pre_process[temp_list[j]]
	pre_process[i]=1+min(temp_list)
t=int(input())
while t:
	t-=1
	x=int(input())
	if(x<2):
		print((-1))
	else:
		print((pre_process[x]))
		


for _ in range(eval(input())):
	num = eval(input());
	
	if num == 1:
		print(-1)
	elif num%7 == 0:
		print(num/7)
	else:
		rem = num%7;
		if rem == 2 or rem == 3 or rem == 5:
			print(num/7 + 1);
		elif rem == 4 or rem == 6:
			print(num/7 + 2);
		else:
			print(num/7 + 1)