Problem:


Carry a Cheese

Jerry is a little mouse. He is trying to survive from the cat Tom. Jerry is carrying a parallelepiped-like piece of cheese of size A &times; B &times; C. It is necessary to trail this cheese to the Jerry's house. There are several entrances in the Jerry's house. Each entrance is a rounded hole having its own radius R. Could you help Jerry to find suitable holes to be survive?

Your task is to create a program which estimates whether Jerry can trail the cheese via each hole.
The program should print "OK" if Jerry can trail the cheese via the corresponding hole (without touching it). Otherwise the program should print "NA".

You may assume that the number of holes is less than 10000.

Input

The input is a sequence of datasets. The end of input is indicated by a line containing three zeros. Each dataset is formatted as follows:

A B C
n
R1
R2

 .
 .
Rn

n indicates the number of holes (entrances) and Ri indicates the radius of i-th hole.

Output

For each datasets, the output should have n lines. Each line points the result of estimation of the corresponding hole. 

Sample Input

10 6 8
5
4
8
6
2
5
0 0 0

Output for the Sample Input

NA
OK
OK
NA
NA



Sample input:
10 6 8
5
4
8
6
2
5
0 0 0


Sample output:
NA
OK
OK
NA
NA

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Created    : 2015-05-12

l = map(int, input().split())
m = min(l)

for _ in range(int(input())):
    if int(input()) >= m:
        print("OK")
    else:
        print("NA")

Submission status: Wrong Answer

Solution code:
while True:
    solid = sorted(map(int, raw_input().split()))
    print solid
    if solid.count(0) == 3: break
    n = input()
    r = []
    s = (solid[0]**2+solid[1]**2)/4
    for i in range(n):
        r.append(input())
        if r[i]*r[i] > s:
            print 'OK'
        else:
            print 'NA'

Submission status: Wrong Answer

Solution code:
while True:
    solid = sorted(map(int, raw_input().split()))
    print solid
    if solid.count(0) == 3: break
    n = input()
    s = (solid[0]**2+solid[1]**2)/4
    for i in range(n):
        r = input()
        if r*r > s:
            print 'OK'
        else:
            print 'NA'

Submission status: Wrong Answer

Solution code:
A, B, C = map(int, raw_input().split())
n = input()

r = min([((A**2)+(B**2))**0.5, ((A**2)+(C**2))**0.5, ((B**2)+(C**2))**0.5])

for i in range(n):
    if (input()*2 > r): print "OK"
    else: print "NA"

Submission status: Wrong Answer

Solution code:
import math

def doc_string():
	"""
	I can fly.
	"""

while True:
	tz = map(int,raw_input().split())
	if tz[0] == 0 and tz[1] == 0 and tz[2] == 0:
		break
	sorted(tz)
	til = math.hypot(tz[0], tz[1]) / 2
	for i in xrange(int(raw_input())):
		gate = int(raw_input())
		if gate > til:
			print "OK"
		else:
			print "NA"

Submission status: Wrong Answer

Solution code:
a = list(map(int,raw_input().split()))
x = sorted(a)[0]
y = sorted(a)[1]
R = (x * 0.5) ** 2 + (y * 0.5) ** 2
n = input()
for i in range(n):
    if (int(raw_input())) ** 2 > R:
        print 'OK'
    else:
        print 'NA'

Submission status: Wrong Answer

Solution code:
x,y,z=map(int,raw_input().split())
tmp=min([x**2+y**2,x**2+z**2,y**2+z**2])
n=int(raw_input())
for i in range(n):
    r=int(raw_input())
    print 'OK' if (r*2)**2>tmp else 'NA'

Submission status: Wrong Answer

Solution code:
x,y,z=map(int,raw_input().split())
tmp=min([x**2+y**2,x**2+z**2,y**2+z**2])
n=int(raw_input())
for i in range(n):
    r=int(raw_input())
    print 'OK' if (r**2)*2>tmp else 'NA'

Submission status: Wrong Answer

Solution code:
x,y,z=map(int,raw_input().split())
tmp=min([x**2+y**2,x**2+z**2,y**2+z**2])
n=int(raw_input())
for i in range(n):
    r=int(raw_input())
    print 'OK' if (r**2)*4>tmp else 'NA'

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
"""
import sys


def solve(d, w, h, holes):
    result = []
    # ???????????\????????£?????¢???1????????????: ????????????r x 2**0.5
    for r in holes:
        side_max = max(w, h)
        if r*2**0.5 >= side_max:
            result.append('OK')
        else:
            result.append('NA')
    return result


def main(args):
    while True:
        #d, w, h = 10, 6, 8
        #holes = [4, 8, 6, 2, 5]
        d, w, h = [int(x) for x in input().split(' ')]
        if d == 0 and w == 0 and h == 0:
            break
        num = int(input())
        holes = [int(input()) for _ in range(num)]
        result = solve(d, w, h, holes)
        for r in result:
            print(r)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
while True:
    d, w, h = [int(x) for x in input().split()]
    minrad = min(d*d+w*w,w*w+h*h,h*h+d*d)
    if minrad == 0:
        break
    n = int(input())
    for i in range(n):
        r = int(input())
        if 2*r*r > minrad:
            print('OK')
        else:
            print('NA')

Submission status: Wrong Answer

Solution code:
import math
while True:
	d,w,h = map(int,input().split())
	if d == 0:
		break
	n = int(input())
	dist = [d**2+w**2, d**2+h**2, w**2+h**2]
	leng = min(dist)
	for i in range(n):
		if leng-int(input()) > 0:
			print('OK')
		else:
			print('NA')

Submission status: Wrong Answer

Solution code:
import math
while True:
	d,w,h = map(int,input().split())
	if d == 0:
		break
	n = int(input())
	dist = [d**2+w**2, d**2+h**2, w**2+h**2]
	leng = min(dist)
	for i in range(n):
		if int(input())-leng > 0:
			print('OK')
		else:
			print('NA')

Submission status: Wrong Answer

Solution code:
import math
while True:
	d,w,h = map(int,input().split())
	if d == 0:
		break
	n = int(input())
	dist = [math.sqrt(d**2+w**2), math.sqrt(d**2+h**2), math.sqrt(w**2+h**2)]
	leng = min(dist)
	for i in range(n):
		if int(input())-leng > 0:
			print('OK')
		else:
			print('NA')

Submission status: Wrong Answer

Solution code:
a,b,_=sorted(list(map(int,input().split())))
for _ in[0]*int(input()):
 r=int(input())
 print("OK"if r*r*4>a*a+b*b else"NA")
input()

Submission status: Wrong Answer

Solution code:
import sys
i=iter(sys.stdin)
for k,s in zip(i,i):
 if'0'==k:break
 s=list(map(int,s.split()))
 c=0
 while 1:
  t=s;s=[t.count(e)for e in t]
  if t==s:break
  c+=1
 print(c);print(*s)

Submission status: Wrong Answer

Solution code:
import sys
for a in sys.stdin:
 if' 'in a:
  s=list(map(int,a.split()))
  c=0
  while 1:
   t=s;s=[t.count(e)for e in t]
   if t==s:break
   c+=1
  print(c);print(*s)

Submission status: Wrong Answer

Solution code:
import sys
for a in sys.stdin:
 if'0'in a:break
 if' 'in a:
  s=list(map(int,a.split()))
  c=0
  while 1:
   t=s;s=[t.count(e)for e in t]
   if t==s:break
   c+=1
  print(c);print(*s)

Submission status: Wrong Answer

Solution code:
import sys,itertools

def ch(l,r):
    t=itertools.combinations(l,2)
    for i in t:
        if i[0]**2+i[1]**2<4*r**2:
            return True
    return False

l=list(map(int,input().split()))
o=[ch(l,int(input())) for i in range(int(input()))] 
input()
[print("OK") if i else print("NA") for i in o]

Submission status: Wrong Answer

Solution code:
import itertools

def ch(l,r):
    t=itertools.combinations(l,2)
    for i in t:
        if i[0]**2+i[1]**2<4*r**2:
            return True
    return False

l=list(map(int,input().split()))
o=[ch(l,int(input())) for i in range(int(input()))] 
input()
[print("OK") if i else print("NA") for i in o]

Submission status: Wrong Answer

Solution code:
import math

results = []
while True:
    line = raw_input()
    if line == '0 0 0':
        for r in results:
            print r
        break
    else:
        t = [int(n) for n in line.split()]
        t.sort()
        size = int(math.ceil(math.sqrt(t[0] * t[0] + t[1] * t[1])))
        entry = input()
        for i in range(entry):
            if 2 * input() > size:
                results.append('OK')
            else:
                results.append('NA')

Submission status: Wrong Answer

Solution code:
import math

results = []
while True:
    line = raw_input()
    if line == '0 0 0':
        for r in results:
            print r
        break
    else:
        t = [int(n) for n in line.split()]
        t.sort()
        size = math.ceil(math.sqrt(t[0] * t[0] + t[1] * t[1]))
        entry = input()
        for i in range(entry):
            if 2 * input() > size:
                results.append('OK')
            else:
                results.append('NA')

Submission status: Wrong Answer

Solution code:
from math import sqrt
cheeze = map(float,raw_input().split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
holel = int(raw_input())
for hole in xrange(holel):
	k = raw_input()
	k = int(k)
	if k < supk: print "OK"
	else: print "NA"

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt
nyu = sys.stdin.readlines()
cheeze = map(float,nyu[0].split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
holel = int(nyu[1])
for holei in xrange(holel):
	k = int(nyu[2+holei])
	if k < supk: print "OK"
	else: print "NA"

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt
nyu = sys.stdin.readlines()
#nyu = ["10 8 6",5,5,7,6,4,5]
cheeze = map(float,nyu[0].split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
holel = int(nyu[1])
for holei in xrange(holel):
	k = int(nyu[2+holei])
	if k < supk: print "OK"
	else: print "NA"

Submission status: Wrong Answer

Solution code:
from math import sqrt
cheeze = map(float,raw_input().split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
holel = int(raw_input())
try:
	for holei in xrange(holel):
		k = int(raw_input())
		if k < supk: print "OK"
		else: print "NA"
except:
	pass

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheeze = map(float,nyu[0].split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
nyu = nyu[2:]
for k in nyu:
	if k < supk: print "OK"
	else: print "NA"

Submission status: Wrong Answer

Solution code:
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheese = map(float,nyu[0].split())
cheese.sort()
supk = sqrt((cheese[0]/2)**2 + (cheese[1]/2)**2)
nyu = nyu[2:]
try:
	for k in nyu:
		if k < supk: print "OK"
		else: print "NA"
except:
	pass

Submission status: Wrong Answer

Solution code:
from sys import stdin
from math import sqrt

cs = map(int,stdin.readline().split())
cs.sort()
c = sqrt(cs[0]**2 + cs[1]**2)/2

n=int(stdin.readline())

for gomi in xrange(n):
    r = int(stdin.readline())
    if c<r: print "OK"
    else: print "NA"

Submission status: Accepted

Solution code:
while True:
    size = map(int,raw_input().split())
    if size[0] == size[1] == size[2] == 0:
        break
    size = sorted(size)
    rmin2 = size[0]**2 + size[1]**2
    
    n = input()
    for i in range(n):
        R2 = 4 * input()**2
        if rmin2 < R2:
            print 'OK'
        else:
            print 'NA'

Submission status: Accepted

Solution code:
while True:
    size = map(int,raw_input().split())
    if size[0] == 0:
        break
    size = sorted(size)
    rmin2 = size[0]**2 + size[1]**2
    
    n = input()
    for i in range(n):
        R2 = (input()**2)*4
        if rmin2 < R2:
            print 'OK'
        else:
            print 'NA'

Submission status: Accepted

Solution code:
while 1:
  a,b,c=sorted(map(int,raw_input().split()))
  if a==b==c==0: break
  D=(a*a+b*b)**.5
  for _ in [0]*input(): print ["NA","OK"][2*input()>D]

Submission status: Accepted

Solution code:
while 1:
  a,b,c=sorted(map(int,raw_input().split()))
  if a==b==c==0: break
  D=a*a+b*b
  n=input()
  for _ in [0]*n:
    r=input()
    print ["NA","OK"][4*r**2>D]

Submission status: Accepted

Solution code:
def hantei(A,B,C,R=0):
    p,q = sorted([A,B,C])[:2]
    if p**2 + q**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
        if (A,B,C) == (0,0,0):
            break
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))

Submission status: Accepted

Solution code:
while(1):
    size=sorted([int(x) for x in raw_input().split()])
    if size[0]==0:
        break
    else:
        cr=size[0]**2+size[1]**2
        n=int(raw_input())
        for i in range(n):
            r=int(raw_input())
            if 4*r**2>cr:
                print 'OK'
            else:
                print 'NA'

Submission status: Accepted

Solution code:
while True:
    solid = sorted(map(int, raw_input().split()))
    if solid.count(0) == 3: break
    n = input()
    s = (solid[0]**2+solid[1]**2)/4
    for i in range(n):
        r = input()
        if r*r > s:
            print 'OK'
        else:
            print 'NA'

Submission status: Accepted

Solution code:
while True:
    A, B, C = map(int, raw_input().split())
    if A == 0: break;   
    n = input()
    r = min([((A**2)+(B**2))**0.5, ((A**2)+(C**2))**0.5, ((B**2)+(C**2))**0.5])
    for i in range(n):
        if (input()*2 > r): print "OK"
        else: print "NA"

Submission status: Accepted

Solution code:
import math

def Tom_and_Jerry():
    for i in range(int(raw_input())):
        r = int(raw_input())
        if r > t:
            print 'OK'
        else:
            print 'NA'

while True:
    h, w, d = map(int, raw_input().split(' '))
    if h == 0: break
    
    a = math.sqrt(h**2 + w**2) / 2.0
    b = math.sqrt(h**2 + d**2) / 2.0
    c = math.sqrt(w**2 + d**2) / 2.0
    if a < b and a < c:
        t = a
    elif b < a and b < c:
        t = b
    elif c < a and c < b:
        t = c
    
    Tom_and_Jerry()

Submission status: Accepted

Solution code:
import math

def doc_string():
	"""
	I can fly.
	"""

while True:
	tz = map(int,raw_input().split())
	if tz == [0,0,0]:
		break

	til = math.hypot(*sorted(tz)[:2]) / 2
	for i in xrange(int(raw_input())):
		gate = int(raw_input())
		if gate > til:
			print "OK"
		else:
			print "NA"

Submission status: Accepted

Solution code:
while True:
  l = [int(i) for i in input().split()]
  if l == [0,0,0]:
    break
  l.sort()
  r = (l[0]**2+l[1]**2)**(1/2)/2
  n = int(input())
  for i in range(n):
    r1 = int(input())
    if r < r1:
      print('OK')
    else:
      print('NA')

Submission status: Accepted

Solution code:
def sol():
    tmp=min([x**2+y**2,x**2+z**2,y**2+z**2])
    n=int(raw_input())
    for i in range(n):
        r=int(raw_input())
        print 'OK' if (r**2)*4>tmp else 'NA'

while 1:
    x,y,z=map(int,raw_input().split())
    if min(x,y,z)==0:
        break
    else:
        sol()

Submission status: Accepted

Solution code:
import math

while True:
    d, w, h = [int(x) for x in input().split()]
    if d == w == h == 0:
        break
    dw = math.sqrt(d * d + w * w)
    dh = math.sqrt(d * d + h * h)
    wh = math.sqrt(w * w + h * h)
    min_ = min(dw, dh, wh)
    n = int(input())
    for i in range(n):
        r = int(input()) * 2
        if r > min_:
            print('OK')
        else:
            print('NA')

Submission status: Accepted

Solution code:
while True:
    try:
        d, w, h = list(map(int, input().split()))
        if d == w == h == 0:
            break
        n = int(input())
        r = []
        for i in range(n):
            r = int(input())
            if r ** 2 > (d ** 2 + w ** 2) / 4 \
                or r ** 2 > (d ** 2 + h ** 2) / 4 \
                or r ** 2 > (h ** 2 + w ** 2) / 4 :
                print("OK")
            else:
                print("NA")
    except EOFError:
        break

Submission status: Accepted

Solution code:
import math

while True:
	l1, l2, l3 = sorted(list(int(i) for i in input().split()))
	if l1 == l2 == l3 == 0:
		break
	n = int(input())
	R = math.sqrt(l1 ** 2 + l2 ** 2) / 2
	for i in range(n):
		r = int(input())
		if r > R:
			print('OK')
		else:
			print('NA')

Submission status: Accepted

Solution code:
while True:
    Size_lis = list(map(int,input().split()))
    if Size_lis == [0,0,0]:
        break
    n = int(input())
    Size_lis.remove(max(Size_lis))
    m_r = (Size_lis[0] / 2) ** 2 + (Size_lis[1] / 2) ** 2

    for i in range(n):
        r = int(input())
        if m_r >= r ** 2:
            print("NA")
        else:
            print("OK")

Submission status: Accepted

Solution code:
while 1:
    a,b,_=sorted(map(int,input().split()))
    if a==0:break
    c=(a**2+b**2)**0.5
    for _ in range(int(input())):print('OK' if c<int(input())*2 else 'NA')

Submission status: Accepted

Solution code:
while 1:
    a,b,_=sorted(map(int,input().split()))
    if a==0:break
    c=(a**2+b**2)**0.5//2
    for _ in range(int(input())):print('OK' if c<int(input()) else 'NA')

Submission status: Accepted

Solution code:
def min_diam(A,B,C): # returns a "diameter"
  segments=[A,B,C]
  segments.sort()
  return (segments[0]**2+segments[1]**2)**(1/2)

while True:
  # input one dataset
  A,B,C = tuple(map(float,input().split()))
  if (A,B,C) == (0,0,0):
    break
  n = int(input())
  R = [None]*n
  for i in range(n):
    R[i] = float(input())
  # process
  diam = min_diam(A,B,C)
  # judge & output
  for r in R:
    if diam < 2*r:
      print("OK")
    else:
      print("NA")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

for s in sys.stdin:
    d, w, h = map(int, s.split())
    if d == w == h == 0:
        break

    lst = [d, w, h]
    lst.sort()
    diameter = math.sqrt(lst[0] ** 2 + lst[1] ** 2)

    n = int(input())

    for i in range(n):
        r = int(input())
        if 2 * r > diameter:
            print('OK')
        else:
            print('NA')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import sys
import os
import math
 
for s in sys.stdin:
    d, w, h = map(int, s.split())
    if d == w == h == 0:
        break
 
    lst = [d, w, h]
    lst.sort()
    diameter = math.sqrt(lst[0] ** 2 + lst[1] ** 2)
 
    n = int(input())
 
    for i in range(n):
        r = int(input())
        if 2 * r > diameter:
            print('OK')
        else:
            print('NA')

Submission status: Accepted

Solution code:
while True:
    d, w, h = map(int, input().split())
    if d == 0:
        break
    n = int(input())
    a, b = sorted([d, w, h])[:2]
    t = pow(pow(a, 2) + pow(b, 2), 0.5) // 2
    for _ in range(n):
        print("OK" if int(input()) > t else "NA")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
"""
import sys


def solve(d, w, h, holes):
    result = []
    diagonal_len = (w**2 + h**2)**0.5
    for r in holes:
        if r*2 > diagonal_len:
            result.append('OK')
        else:
            result.append('NA')
    # ???????????\????????£?????¢???1????????????: ????????????r x 2**0.5
    #for r in holes:
    #    side_max = max(w, h)
    #    if r*2**0.5 >= side_max:
    #       result.append('OK')
    #    else:
    #        result.append('NA')
    return result


def main(args):
    while True:
        #d, w, h = 10, 6, 8
        #holes = [4, 8, 6, 2, 5]
        d, w, h = [int(x) for x in input().strip().split(' ')]
        if d == 0 and w == 0 and h == 0:
            break
        num = int(input())
        holes = [int(input().strip()) for _ in range(num)]
        result = solve(d, w, h, holes)
        for r in result:
            print(r)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# Aizu Problem 0107: Carry a Cheese
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    a, b, c = sorted([int(_) for _ in input().split()])
    R = .5 * math.sqrt(a**2 + b**2)
    if a == b == c == 0:
        break
    N = int(input())
    for _ in range(N):
        r = int(input())
        print("OK" if r > R else "NA")

Submission status: Accepted

Solution code:
while True:
    d, w, h = [int(x) for x in input().split()]
    minrad = min(d*d+w*w,w*w+h*h,h*h+d*d)
    if minrad == 0:
        break
    n = int(input())
    for i in range(n):
        r = int(input())
        if 4*r*r > minrad:
            print('OK')
        else:
            print('NA')

Submission status: Accepted

Solution code:
import math
while True:
	d,w,h = map(int,input().split())
	if d == 0:
		break
	n = int(input())
	dist = [math.sqrt(d**2+w**2), math.sqrt(d**2+h**2), math.sqrt(w**2+h**2)]
	leng = min(dist)
	for i in range(n):
		if 2*int(input())-leng > 0:
			print('OK')
		else:
			print('NA')

Submission status: Accepted

Solution code:
import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    while True:
        l = list(map(int,sys.stdin.readline().split(' ')))
        if l[0] == 0: break
        l.sort();
        n = int(sys.stdin.readline())
        for i in range(n):
            r = int(sys.stdin.readline())
            if r*r*4>l[0]*l[0]+l[1]*l[1]:
                print("OK")
            else:
                print("NA")
solve()

Submission status: Accepted

Solution code:
import math

output = []

while True:
    depth, width, height = [int(item) for item in input().split(" ")]

    if depth == 0 and width == 0 and height == 0:
        break

    cheeseRadius = math.sqrt((width / 2)**2 + (height / 2)**2)

    inputCount = int(input())

    for lp in range(inputCount):
        entranceRadius = int(input())

        if cheeseRadius < entranceRadius:
            output.append("OK")
        else:
            output.append("NA")

print("\n".join(output))

Submission status: Accepted

Solution code:
while 1:
 a,b,_=sorted(map(int,input().split()))
 if a==0:break
 for _ in[0]*int(input()):
  r=int(input())
  print("OK"if r*r*4>a*a+b*b else"NA")

Submission status: Accepted

Solution code:
while 1:
 a,b,_=sorted(map(int,input().split()))
 if a==0:break
 for _ in[0]*int(input()):print("OK"if (int(input())*2)**2>a*a+b*b else"NA")

Submission status: Accepted

Solution code:
while 1:
 a,b,_=sorted(map(int,input().split()))
 if a==0:break
 for _ in[0]*int(input()):print("OK"if(int(input())*2)**2>a*a+b*b else"NA")

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

while True:
    d = [int(i) for i in input().split()]
    if d[0] == 0 and d[1] == 0 and d[2] == 0:
        break

    d.sort()
    cheese = d[0] * d[0] + d[1] * d[1]

    N = int(input())
    for l in range(N):
        R = int(input())*2
        if cheese < R*R:
            print("OK")
        else:
            print("NA")

Submission status: Accepted

Solution code:
while True:
  lst = list(map(int, input().split()))
  if not lst[0]:
    break
  lst.sort()
  rad = (lst[0] ** 2 + lst[1] ** 2 ) ** (1 / 2) / 2  
  n = int(input())
  for _ in range(n):
    print("OK" if int(input()) > rad else "NA")

Submission status: Accepted

Solution code:
import itertools

def ch(l,r):
    t=itertools.combinations(l,2)
    for i in t:
        if i[0]**2+i[1]**2<4*r**2:
            return True
    return False

while 1:
    l=list(map(int,input().split()))
    if l[0]==0 and l[1]==0 and l[2]==0:break
    o=[ch(l,int(input())) for i in range(int(input()))] 
    [print("OK") if i else print("NA") for i in o]

Submission status: Accepted

Solution code:
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	vmin = min(d*d+w*w, d*d+h*h, w*w+h*h)

	for _ in range(int(input())):
		r = int(input())
		print('OK' if (2*r)**2 > vmin else 'NA')

Submission status: Accepted

Solution code:
import math

results = []
while True:
    line = raw_input()
    if line == '0 0 0':
        for r in results:
            print r
        break
    else:
        t = [int(n) for n in line.split()]
        t.sort()
        size = math.sqrt(t[0] * t[0] + t[1] * t[1])
        entry = input()
        for i in range(entry):
            if float(2 * input()) > size:
                results.append('OK')
            else:
                results.append('NA')

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    a, b, c = map(int, raw_input().split())
    if a == 0 and b == 0 and c == 0:
        break

    d1, d2, d3 = sqrt(a**2 + b**2), sqrt(b**2 + c**2), sqrt(c**2 + a**2)

    for i in range(int(raw_input())):
        r = int(raw_input())
        if d1 < r * 2 or d2 < r * 2 or d3 < r * 2:
            print "OK"
        else:
            print "NA"

Submission status: Accepted

Solution code:
while True:
    le=map(float,raw_input().split())
    if le==[0,0,0]:
        break
    mdl=min([(le[i-1]**2+le[i]**2)**0.5 for i in xrange(3)])
    for u in xrange(input()):
        if input()*2>mdl:
            print "OK"
        else:
            print "NA"

Submission status: Accepted

Solution code:
import math
while 1:
    es = map(int, raw_input().split())
    if es == [0, 0, 0]: break
    r = math.hypot(*sorted(es)[:2]) / 2
    for i in range(int(raw_input())):
        print 'OK' if int(raw_input()) > r else 'NA'

Submission status: Accepted

Solution code:
import math
while True:
    l,w,h=map(int,raw_input().split())
    if l==w==h==0:
        break
    n=input()
    for i in range(n):
        r=input()
        leng=math.sqrt(pow(w,2)+pow(h,2))/2
        if r>leng:
            print "OK"
        else:
            print "NA"

Submission status: Accepted

Solution code:

import sys
import math


def solv(l, w, h, ent):
    cheese = [l, w, h]
    cheese.pop(cheese.index(max(cheese)))
    diagonal = math.sqrt(cheese[0] ** 2 + cheese[1] ** 2)
    ent_size = map(lambda x: x * 2, ent)
    for size in ent_size:
        if diagonal < size:
            print 'OK'
        else:
            print 'NA'


while True:
    l, w, h = tuple(map(int, sys.stdin.readline().split(' ')))
    if (l, w, h) == (0, 0, 0):
        exit()
    n = int(sys.stdin.readline())
    ent = []
    for i in range(n):
        ent.append(int(sys.stdin.readline()))
    solv(l, w, h, ent)

Submission status: Accepted

Solution code:
from math import sqrt

while True:
    inp = raw_input()
    if inp == "0 0 0": break
    cs = map(int,inp.split())
    cs.sort()
    c = sqrt(cs[0]**2 + cs[1]**2)/2

    n=int(raw_input())

    for gomi in xrange(n):
        r = int(raw_input())
        if c<r: print "OK"
        else: print "NA"

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit
from math import hypot


def main(readline=stdin.readline):
    answer = ('NA', 'OK')

    while 1:
        height, width, depth = (float(s) for s in readline().split())
        if not height:
            exit()

        hw = hypot(height, width)
        wd = hypot(width, depth)
        dh = hypot(depth, height)

        for _ in range(int(readline())):
            size = float(int(readline()) * 2)
            print(answer[size > hw or size > wd or size > dh])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while 1:
    s=map(int, raw_input().split())
    s.sort()
    if s==[0,0,0]: break
    n = input()
    cr = float(s[0]**2+s[1]**2)/4.0
    for i in xrange(n):
        r = input()
        print "OK" if cr<r**2 else "NA"

Submission status: Accepted

Solution code:
while 1:
    s=map(int, raw_input().split())
    s.sort()
    if s==[0,0,0]: break
    n = input()
    cr = s[0]**2+s[1]**2
    for i in xrange(n):
        r = input()
        print "OK" if cr<4*r**2 else "NA"

Submission status: Accepted

Solution code:
import sys
import math
 
 
def solv(l, w, h, ent):
    cheese = [l, w, h]
    cheese.pop(cheese.index(max(cheese)))
    diagonal = math.sqrt(cheese[0] ** 2 + cheese[1] ** 2)
    ent_size = map(lambda x: x * 2, ent)
    for size in ent_size:
        if diagonal < size:
            print 'OK'
        else:
            print 'NA'
 
 
while True:
    l, w, h = tuple(map(int, sys.stdin.readline().split(' ')))
    if (l, w, h) == (0, 0, 0):
        exit()
    n = int(sys.stdin.readline())
    ent = []
    for i in range(n):
        ent.append(int(sys.stdin.readline()))
    solv(l, w, h, ent)

Submission status: Accepted

Solution code:
import math
while True:
    w,l,h = map(int, raw_input().split())
    if w == 0:
        break
    d = [math.sqrt(w**2+l**2), math.sqrt(l**2+h**2), math.sqrt(h**2+w**2)]
    m = min(d)
    n = int(raw_input())
    for i in range(n):
        r = int(raw_input())
        if 2*r > m:
            print "OK"
        else:
            print "NA"

Submission status: Accepted

Solution code:
while True:
	size = map(int, raw_input().split())
	if sum(size) == 0: break
	size.remove(max(size))
	m = (size[0]**2 + size[1]**2) ** 0.5
	for i in range(input()):
		n = input()
		print "OK" if m < n * 2 else "NA"

Submission status: Accepted

Solution code:
# 長方体の内小さい2辺を元に長方形の外接円を考える
# sqrt(a^2+b^2)/2が長方形の外接円の半径となるため
# r>sqrt(a^2+b^2)/2であれば入口に接さずにチーズを搬入可能
while 1:
    dwh = list(map(int,input().split()))
    if dwh[0]==dwh[1]==dwh[2]==0:
        break
    dwh.sort()
    cir = ((dwh[0]**2 + dwh[1]**2)**(1/2))/2
    n = int(input())
    for i in range(n):
        print("OK" if int(input()) > cir else "NA")

Submission status: Accepted

Solution code:
import math
while True :
    d, w, h = map(int, input().split())
    if d == 0 and w == 0 and h == 0 :
        break
    
    length = [d, w, h]
    len_1 = sorted([d, w, h])[0]
    len_2 = sorted([d, w, h])[1]
    max_d = math.sqrt(len_1**2 + len_2**2)
    
    n = int(input())
    for i in range(n) :
        r = int(input())
        if 2 * r > max_d :
            print("OK")
        else :
            print("NA")

Submission status: Accepted

Solution code:
while True:
    d, w, h = (int(x) for x in input().split())
    if d == 0: break
    q = int(input())
    vmin = min(d * d + w * w, d * d + h * h, w * w + h * h)
    
    for i in range(0,q):
    	r = int(input())
    	ans = 'NA'
    	if (2 * r) ** 2 > vmin:
    	    ans = 'OK'
    	print(ans)

Submission status: Accepted

Solution code:
while True:
  d, w,h =list(map(int, input().split()))
  if d ==0 and w==0 and h==0:
    break
  m = min(d*d+w*w, d*d+h*h, w*w+h*h)
  
  for i in range(int(input())):
    r = int(input())
    if (2*r)**2 >m:
      print("OK")
    else:
      print("NA")