find-the-hub

After decrypting the code Enigma crew came to know that there are N locations where bombs has been planted. X1, X2 …. Xn are the N locations. Among this locations, one X location is the central hub which control all the other Xn-1 location. 1 or more than 1 signal is send to N locations. The decrypted code simplified  that the X location is not divisible from the range 2 to X/2. 

Your job is to help the Enigma crew by finding the largest X location and how many times it is repeated. So, the Enigma crew can defuse the main hub.

Input Format
The first line contains a single integer, N, representing the number of locations.
In the second line, there are N space-separated integers X1, X2 …..Xn, representing the location of N.  

Output Format
There will be two line of output.
First line contain the largest X location.
Second line contain the number of times is repeated. 

Constraints
1 ≤ N ≤ 100000
1 ≤ X ≤ 1000000

SAMPLE INPUT
10
1 3 5 17 21 17 5 11 10 40

SAMPLE OUTPUT
17
2

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
import math
t=int(input())
s=(input())
u=list(map(int,s.split()))
i=0
q=[]
while i<t:
	j=2
	c=0
	k=math.sqrt(u[i])
	while j<=(k):
		y=u[i]%j
		if y != 0:
			j=j+1
		else:
			c=c+1
			break
	if c==0:
		q.append(u[i])
	i=i+1
x=max(q)
print(x)
print(u.count(x))

		


def isPrime(n):
	l =int(n**0.5)
	for i in range(2,l):
		if n%i==0 :
			return False
			break
	return True

t = int(input())
m=0
arr = [int(i) for i in input().split()]
for ele in arr:
	if isPrime(ele) == True:
		if(ele>m):
			m=ele
print(m)
print(arr.count(m))




def checkDiv(x):
	for j in range(2,(x//2)+1):
		if x % j==0:
			return False
	return True

if __name__=='__main__':
	n = int(input())
	num = list(map(int,input().split()))
	arr = sorted(num)[::-1]
	for i in arr:
		if checkDiv(i):
			k=i
			break
	
	print(k)
	print(arr.count(k))


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math

def is_prime(number):
	
	sq = int(math.sqrt(number))
	for i in range(2, sq):
		if number % i == 0:
			return False
			
	return True
	
	
def frequency(numbers):
	freq = {}
	
	for number in numbers:
		if number in freq:
			freq[number] += 1
		else:
			freq[number] = 1
			
	return freq
	
	
def main(numbers):
	
	freq = frequency(numbers)
	max_freq = 0
	freq_num = 0
	
	for number in numbers:
		if is_prime(number) and number > freq_num:
			max_freq = freq[number]
			freq_num = number
	
	return freq_num, max_freq
	
	
if __name__ == '__main__':
	
	num = int(input())
	numbers = list(map(int, input().split()))
	
	freq_num, max_freq = main(numbers)
	
	print(freq_num)
	print(max_freq)