Search is not available for this dataset
name
stringlengths 2
88
| description
stringlengths 31
8.62k
| public_tests
dict | private_tests
dict | solution_type
stringclasses 2
values | programming_language
stringclasses 5
values | solution
stringlengths 1
983k
|
---|---|---|---|---|---|---|
brcktsrm | Problem description.
Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hardship.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single string S denoting the string to be checked.
Output
For each test case, output a single line printing "YES" or "NO" (without " " and in uppercase only) , denoting if the brackets in the given string is balanced or not .
Constraints
1 ≤ T ≤ 10
1 ≤ length of S ≤ 60
Example
Input:
3
((()))
(())()
()(()
Output:
YES
YES
NO
Explanation
Example is self-explanatory. | {
"input": [
"3\n((()))\n(())()\n()(()"
],
"output": [
"YES\nYES\nNO"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | for _ in range(input()):
try:
eval(raw_input())
print 'YES'
except TypeError:
print 'YES'
except:
print 'NO' |
brcktsrm | Problem description.
Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hardship.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single string S denoting the string to be checked.
Output
For each test case, output a single line printing "YES" or "NO" (without " " and in uppercase only) , denoting if the brackets in the given string is balanced or not .
Constraints
1 ≤ T ≤ 10
1 ≤ length of S ≤ 60
Example
Input:
3
((()))
(())()
()(()
Output:
YES
YES
NO
Explanation
Example is self-explanatory. | {
"input": [
"3\n((()))\n(())()\n()(()"
],
"output": [
"YES\nYES\nNO"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | for _ in range(input()):
ins = raw_input().strip()
stck = []
res = "YES"
for x in ins:
if x == "(":
stck.append(x)
else:
if len(stck)>0:
stck.pop()
else:
res = "NO"
break
if len(stck) > 0: res = "NO"
print res |
brcktsrm | Problem description.
Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friend help him in his time of hardship.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single string S denoting the string to be checked.
Output
For each test case, output a single line printing "YES" or "NO" (without " " and in uppercase only) , denoting if the brackets in the given string is balanced or not .
Constraints
1 ≤ T ≤ 10
1 ≤ length of S ≤ 60
Example
Input:
3
((()))
(())()
()(()
Output:
YES
YES
NO
Explanation
Example is self-explanatory. | {
"input": [
"3\n((()))\n(())()\n()(()"
],
"output": [
"YES\nYES\nNO"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | for _ in range(input()):
try: eval(raw_input()); print 'YES'
except TypeError: print 'YES'
except: print 'NO' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
no_of_testcases = int(input())
for each in range(no_of_testcases):
dist = int(input())
point_1 = map(int,raw_input().split())
point_2 = map(int,raw_input().split())
point_3 = map(int,raw_input().split())
point_12 =math.sqrt( math.pow((point_1[0] -point_2[0]),2) + math.pow((point_1[1] -point_2[1]),2))
point_23 =math.sqrt( math.pow((point_2[0] -point_3[0]),2) + math.pow((point_2[1] -point_3[1]),2))
point_31 =math.sqrt( math.pow((point_3[0] -point_1[0]),2) + math.pow((point_3[1] -point_1[1]),2))
count =0
if point_12 <= dist:
count =count+1
if point_23 <= dist:
count =count+1
if point_31 <= dist:
count =count+1
if count >=2:
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def distance(x1,y1,x2,y2):
dist = ((x1-x2)**2 + (y1-y2)**2)**0.5
return dist
t = input()
for i in range(t):
r = input()
chef_x,chef_y = map(int,raw_input().split(' '))
head_server_x,head_server_y = map(int,raw_input().split(' '))
sous_chef_x,sous_chef_y = map(int,raw_input().split(' '))
chef_head_server_distance = distance(chef_x,chef_y,head_server_x,head_server_y)
chef_sous_chef_distance = distance(chef_x,chef_y,sous_chef_x,sous_chef_y)
sous_chef_head_server_distance = distance(sous_chef_x, sous_chef_y, head_server_x, head_server_y)
communicate = 0
if(chef_head_server_distance <= r):
communicate+=1
if(chef_sous_chef_distance <= r):
communicate+=1
if(sous_chef_head_server_distance <= r):
communicate+=1
if(communicate >= 2):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | #COMM3
test = input()
while test > 0:
test -= 1
dist = input()**2
a,b = map(int, raw_input().split())
c,d = map(int, raw_input().split())
e,f = map(int, raw_input().split())
dist1 = (a-c)**2 + (b-d)**2
dist2 = (a-e)**2 + (b-f)**2
dist3 = (c-e)**2 + (d-f)**2
if (dist1 <= dist and dist2 <=dist) or (dist2 <= dist and dist3 <=dist) or (dist1 <= dist and dist3 <=dist):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from sys import stdin as ip
for _ in xrange(int(ip.readline())):
r=int(ip.readline())**2
a,b=map(int,ip.readline().split())
x,y=map(int,ip.readline().split())
p,q=map(int,ip.readline().split())
d1=pow(x-a,2)+pow(y-b,2)
d2=pow(p-x,2)+pow(q-y,2)
d3=pow(p-a,2)+pow(q-b,2)
if d1<=r and d2<=r or d2<=r and d3<=r or d1<=r and d3<=r:
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math as m
def leng(a,c,b,d):
return m.sqrt(((a-c)**2)+((b-d)**2))
t=input()
ans=[]
for i in range(t):
n=input()
x1,y1=raw_input().split()
x2,y2=raw_input().split()
x3,y3=raw_input().split()
d1=leng(int(x1),int(x2),int(y1),int(y2))
d2=leng(int(x1),int(x3),int(y1),int(y3))
d3=leng(int(x3),int(x2),int(y3),int(y2))
l=[d1,d2,d3]
l.sort()
if l[0]<=n and l[1]<=n and l[0]+l[1]>=l[2]:
ans.append('yes')
else:
ans.append('no')
for i in range(t):
print ans[i] |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | t=input()
def dist(a,b,c,d):
return (((a-c)**2)+((b-d)**2))**0.5
for i in range(0,t):
r=input()
e=[]
for j in range(0,3):
e.append(map(int,raw_input().split(' ')))
if dist(e[0][0],e[0][1],e[2][0],e[2][1])<=r:
print "yes"
elif dist(e[0][0],e[0][1],e[1][0],e[1][1])<=r and dist(e[1][0],e[1][1],e[2][0],e[2][1])<=r:
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 16 12:29:47 2016
@author: matteoarno
"""
import sys
data = sys.stdin.readlines()
t = int(data.pop(0))
output = []
for i in range(t):
r = int(data.pop(0))
chef = map(int,(data.pop(0).split(' ')))
head = map(int,(data.pop(0).split(' ')))
sous = map(int,(data.pop(0).split(' ')))
def distance (first, second):
dist = ((first[0]-second[0])**2 + (first[1]-second[1])**2)**(0.5)
return dist
ch = distance(chef, head)
hs = distance(head, sous)
cs = distance(chef, sous)
if ch > r:
if (hs <= r and cs <= r):
output.append('yes')
else:
output.append('no')
else:
if (hs <= r or cs <= r):
output.append('yes')
else:
output.append('no')
for k in output:
print k |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
def cal_dist(x1,y1,x2,y2):
dis = math.sqrt(((x1-x2)**2)+((y1-y2)**2))
return dis
test = int(input())
while test:
R = int(input())
cx1,cy1=map(int, raw_input().split())
cx2,cy2=map(int, raw_input().split())
cx3,cy3=map(int, raw_input().split())
d1 = cal_dist(cx1,cy1,cx2,cy2)
d2 = cal_dist(cx1,cy1,cx3,cy3)
d3 = cal_dist(cx3,cy3,cx2,cy2)
if((d1<=R and d2<=R) or (d1<=R and d3<=R) or (d3<=R and d2<=R)):
print "yes"
else:
print "no"
test = test-1 |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
def distance(x1, y1, x2, y2):
return math.sqrt((x2-x1)**2 + (y2-y1)**2)
import math
n = int(raw_input())
rs = []
while n != 0:
max_d = int(raw_input())
p1 = map(int,raw_input().split())
p2 = map(int,raw_input().split())
p3 = map(int,raw_input().split())
ds = []
ds.append(distance(p1[0], p1[1], p2[0], p2[1]))
ds.append(distance(p1[0], p1[1], p3[0], p3[1]))
ds.append(distance(p2[0], p2[1], p3[0], p3[1]))
ds = sorted(ds)
if ds[0] <= max_d and ds[1] <= max_d:
rs.append("yes")
else:
rs.append("no")
n -= 1
for i in rs:
print i |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | class Solution:
def threeWayComm(self):
t = int(raw_input())
while t > 0:
r = int(raw_input())
if r <= 0 or r > 1000:
break
x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
x3, y3 = map(int, raw_input().split())
if x1 > 10000 or y1 > 10000 or x2 > 10000 or y2 > 10000 or x3 > 10000 or y3 > 10000:
break;
count = 0
if self.isClose(x1, y1, x2, y2, r):
count+=1
if self.isClose(x2, y2, x3, y3, r):
count+=1
if self.isClose(x3, y3, x1, y1, r):
count+=1
if count >=2:
print "yes"
else:
print "no"
t -= 1
def isClose(self, a, b, c, d, r):
return (a-c)**2 + (b-d)**2 <= r**2
s = Solution()
s.threeWayComm() |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from math import hypot
t = input()
for _ in xrange(t):
r = input()
x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
x3, y3 = map(int, raw_input().split())
ab = hypot(x1 - x2, y1 - y2)
bc = hypot(x2 - x3, y2 - y3)
ac = hypot(x3 - x1, y3 - y1)
if (ab <= r and bc <= r) or (ab <= r and ac <= r) or (bc <= r and ac <= r):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from math import sqrt
def dist(x1,y1,x2,y2):
a=(abs(x1-x2))**2
b=(abs(y1-y2))**2
return sqrt(a+b)
for testcases in xrange(int(raw_input())):
r=int(raw_input())
x=[]
y=[]
c=0
for i in xrange(3):
a,b=map(int,raw_input().split())
x.append(a)
y.append(b)
if dist(x[0],y[0],x[1],y[1]) <= r:
c+=1
if dist(x[1],y[1],x[2],y[2]) <= r:
c+=1
if dist(x[0],y[0],x[2],y[2]) <= r:
c+=1
if c>=2:
print 'yes'
else:
print 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
t = int(input())
l = []
while(t):
r = int(input())
l = list(map(int, raw_input().split()))
x1 = l[0]
y1 = l[1]
l = list(map(int, raw_input().split()))
x2 = l[0]
y2 = l[1]
l = list(map(int, raw_input().split()))
x3 = l[0]
y3 = l[1]
d1 = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
d2 = math.sqrt((x3 - x2) ** 2 + (y3 - y2) ** 2)
d3 = math.sqrt((x1 - x3) ** 2 + (y1 - y3) ** 2)
if((d1 <= r) and (d2 <= r) and (d3 <= r)):
print "yes"
elif ((d1 <= r) and (d2 <= r) or (d2 <= r) and (d3 <= r) or (d3 <= r) and (d1 <= r)):
print "yes"
else:
print "no"
t -= 1 |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from math import hypot
T=int(raw_input())
for t in range(T):
R=int(raw_input())
x1,y1=map(int,raw_input().split())
x2,y2=map(int,raw_input().split())
x3,y3=map(int,raw_input().split())
dist_1=hypot(x2-x1,y2-y1)
dist_2=hypot(x3-x2,y3-y2)
dist_3=hypot(x3-x1,y3-y1)
if (dist_1 <=R and dist_2 <=R) or (dist_2<=R and dist_3<=R) or (dist_1<=R and dist_3<=R):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def commute():
for i in range(int(raw_input())):
j =int(raw_input())
a = []
for i in range(3):
a.append((map(int,raw_input().split())))
print "yes" if len([i for i in chek(a) if i<=j]) >= 2 else "no"
def chek(a):
return [((a[t][0] - a[(t+1)%3][0])**2 + (a[t][1] - a[(t+1)%3][1])**2)**0.5 for t in range(len(a))]
commute() |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | '''input
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
'''
from math import sqrt
def solve(a, b): return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
for T in range(input()):
d, coords = input(), [[int(i) for i in raw_input().rstrip().split()] for j in range(3)]
dists = []
dists.append(solve(coords[0], coords[1]))
dists.append(solve(coords[1], coords[2]))
dists.append(solve(coords[2], coords[0]))
print 'yes' if len(filter(lambda x: x <= d, dists)) >= 2 else 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def dist(x,y,r):
if ((x[0]-y[0])**2 + (x[1]-y[1])**2)**(0.5) <= r:
return 1
else:
return 0
t = int(raw_input())
for i in xrange(t):
r = float(raw_input())
x = list()
for q in xrange(3):
x += [map(float,raw_input().strip().split())]
isposs = 0
isposs = dist(x[0],x[1],r) + dist(x[0],x[2],r) + dist(x[1],x[2],r)
print 'yes' if (isposs >= 2) else 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def diff(a,b,c,d) :
return float(((a-c)**2 + (b-d)**2)**0.5)
for i in xrange(int(raw_input())) :
k = int(raw_input().strip())
k = float(k)
l = []
for j in xrange(3) :
l.append(map(int,raw_input().split(' ')))
diff_12 = diff(l[0][0],l[0][1],l[1][0],l[1][1])
diff_23 = diff(l[1][0],l[1][1],l[2][0],l[2][1])
diff_13 = diff(l[0][0],l[0][1],l[2][0],l[2][1])
if (diff_12 <= k) and (diff_23 <= k) :
print 'yes'
elif (diff_13 <= k) and (diff_23 <= k) :
print 'yes'
elif (diff_12 <= k) and (diff_13 <= k) :
print 'yes'
else :
print 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | # -*- coding: utf-8 -*-
"""
Created on Wed Jan 27 22:23:20 2016
@author: shashank
"""
import sys
import math
def distance(x,y):
return math.sqrt((x[0] - y[0])**2 + (x[1] - y[1])**2)
T = input()
for i in range(T):
R = input()
chef = [int(x) for x in sys.stdin.readline().split()]
head = [int(x) for x in sys.stdin.readline().split()]
sous = [int(x) for x in sys.stdin.readline().split()]
dist1 = distance(chef,head)
dist2 = distance(chef,sous)
dist3 = distance(sous,head)
if ((dist1 <= R and dist2 <= R) or (dist1 <= R and dist3 <= R) or (dist2 <= R and dist3 <= R)):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def out_of_reach(xyA, xyB, reach):
return ((xyB[0]-xyA[0])**2 + (xyB[1]-xyA[1])**2)**.5 > reach
for tests in xrange(int(raw_input())):
r = int(raw_input())
coordinates = []
for _ in range(3):
coordinates.append(map(int, raw_input().split()))
for pair in coordinates:
t_coordinates = coordinates[:]
t_coordinates.remove(pair)
if len([t_pair for t_pair in t_coordinates if out_of_reach(pair, t_pair, r)]) == 2:
print 'no'
break
else:
print 'yes' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | t=int(raw_input())
for k in range(t):
a=[[],[],[]]
r=int(raw_input())
for j in range (3):
b=map(int,raw_input().split())
a[j].append(b[0])
a[j].append(b[1])
f=0
for j in range(3):
if (pow((a[j][0]-a[(j+1)%3][0]),2)+pow((a[j][1]-a[(j+1)%3][1]),2))<=(float)(r*r) and (pow((a[j][0]-a[(j+2)%3][0]),2)+pow((a[j][1]-a[(j+2)%3][1]),2))<=(float)(r*r):
f=1
break;
if f==1:
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | #!/usr/bin/python
from math import sqrt
N=input()
for i in range(N):
R=input()
x,y=map(int,raw_input().split())
p,q=map(int,raw_input().split())
a,b=map(int,raw_input().split())
l=sqrt(((x-p)**2)+((y-q)**2))
m=sqrt(((x-a)**2)+((y-b)**2))
n=sqrt(((a-p)**2)+((b-q)**2))
#print "(%0.2f %0.2f)->(%0.2f %0.2f) = %0.2f " %(x,y,p,q,l)
#print "(%0.2f %0.2f)->(%0.2f %0.2f) = %0.2f " %(x,y,a,b,m)
#print "(%0.2f %0.2f)->(%0.2f %0.2f) = %0.2f " %(p,q,a,b,n)
count=0
if l>R:
count+=1
if m>R:
count+=1
if n>R:
count+=1
if count>=2:
print "no"
else:
print "yes" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def distance(t1,t2):
return ((t1[0]-t2[0])**2+(t1[1]-t2[1])**2)**0.5
t = int(input())
for test in xrange(t):
r = int(input())
x1,y1 = map(int,raw_input().split())
x2,y2 = map(int,raw_input().split())
x3,y3 = map(int,raw_input().split())
dis_list = map(distance,[(x1,y1),(x1,y1),(x3,y3)],[(x2,y2),(x3,y3),(x2,y2)])
fil_list = filter(lambda x:x>r,dis_list)
if len(fil_list)<2:
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def checker( pt1, pt2, R ) :
dist2 = ( ( (pt1[0] - pt2[0]) **2 ) + ( (pt1[1] - pt2[1]) **2 ) )
return True if (dist2 <= (R**2)) else False
for testcases in xrange(int(raw_input() ) ) :
maxD = int( raw_input() )
A = map(int, raw_input().split() )
B = map(int, raw_input().split() )
C = map(int, raw_input().split() )
commList = [ checker(A, B, maxD), checker(B, C, maxD), checker(C, A, maxD) ]
print 'yes' if commList.count(True) > 1 else 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def is_in_range(x1, y1, x2, y2, limit):
if((x1-x2)*(x1-x2)+((y1-y2)*(y1-y2)) <= limit*limit):
return 1
else:
return 0
tc=int(raw_input())
for _ in range(tc):
limit=int(raw_input())
x1, y1=map(int, raw_input().split())
x2, y2=map(int, raw_input().split())
x3, y3=map(int, raw_input().split())
if(is_in_range(x1, y1, x2, y2,limit) + is_in_range(x1, y1, x3, y3, limit) + is_in_range(x2, y2, x3, y3, limit) > 1):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def dis(x1,y1,x2,y2):
dist=(((x1-x2)**2)+((y1-y2)**2))
return dist
t=int(raw_input())
while(t>0):
x=0
r=int(raw_input())
chefx,chefy=raw_input().split()
chefx,chefy=[int(chefx),int(chefy)]
headx,heady=raw_input().split()
headx,heady=[int(headx),int(heady)]
sousx,sousy=raw_input().split()
sousx,sousy=[int(sousx),int(sousy)]
if(dis(chefx,chefy,headx,heady)<=r*r):
x=x+1
if(dis(chefx,chefy,sousx,sousy)<=r*r):
x=x+1
if(dis(sousx,sousy,headx,heady)<=r*r):
x=x+1
if(x>1):
print "yes"
else:
print "no"
t=t-1 |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import sys
import math
t=int(sys.stdin.readline())
for i in xrange(t):
r=int(sys.stdin.readline())
a=map(int,sys.stdin.readline().split())
b=map(int,sys.stdin.readline().split())
c=map(int,sys.stdin.readline().split())
ab=math.sqrt(((b[0]-a[0])**2)+((b[1]-a[1])**2))
bc=math.sqrt(((b[0]-c[0])**2)+((b[1]-c[1])**2))
ac=math.sqrt(((c[0]-a[0])**2)+((c[1]-a[1])**2))
if ((ab<=r)&(bc<=r))|((bc<=r)&(ac<=r))|((ac<=r)&(ab<=r)):
print 'yes'
else:
print 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
def distance (a, b):
return float(math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2))
for i in range (input()):
maxrange = int(input())
a = [int(j) for j in raw_input().split()]
b = [int(j) for j in raw_input().split()]
c = [int(j) for j in raw_input().split()]
distList = []
distList.append(distance(a, b))
distList.append(distance(b, c))
distList.append(distance(a, c))
if (sum(j > maxrange for j in distList)) >= 2: print "no"
else: print "yes" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | for _ in range(int(raw_input())):
r=int(raw_input())
cx,cy=map(int,raw_input().split())
hsx,hsy=map(int,raw_input().split())
scx,scy=map(int,raw_input().split())
chsd = (((cx-hsx)**2)+((cy-hsy)**2))**0.5
cscd = (((cx-scx)**2)+((cy-scy)**2))**0.5
hsscd= (((scx-hsx)**2)+((scy-hsy)**2))**0.5
c=0
if chsd<=r:
c+=1
if cscd<=r:
c+=1
if hsscd<=r:
c+=1
if c>=2:
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
t = int(raw_input())
def distance(fir,sec):
val1 = int(fir[0]) - int(sec[0])
val2 = int(fir[1]) - int(sec[1])
dis = math.sqrt(val1 * val1 + val2 * val2)
return dis
for i in range(0,t):
R = int(raw_input())
arr1 = []
arr2 = []
arr3 = []
array1 = raw_input()
array2 = raw_input()
array3 = raw_input()
arr1 += array1.split(" ")
arr2 += array2.split(" ")
arr3 += array3.split(" ")
res1 = distance(arr1,arr2)
res2 = distance(arr2,arr3)
res3 = distance(arr1,arr3)
count = 0
if R >= res1 :
count += 1
if R >= res2 :
count += 1
if R >= res3 :
count += 1
if count >= 2:
print("yes")
else:
print("no") |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | t = int(raw_input())
t1 = []
for q in range(t):
x = int(raw_input())
a = []
for i in range(3):
a.append(map(int,raw_input().split()))
for i in range(3):
z = 0
for j in range(3):
if j != i :
if abs((((a[i][1]-a[j][1])**2)+((a[i][0]-a[j][0])**2))**0.5) > x :
for p in range(3):
if p != i and p!= j :
if abs((((a[i][1]-a[p][1])**2)+((a[i][0]-a[p][0])**2))**0.5) <= x and abs((((a[j][1]-a[p][1])**2)+((a[j][0]-a[p][0])**2))**0.5) <= x :
pass
else :
z = 1
if z == 0:
t1.append("yes")
else :
t1.append("no")
for i in range(len(t1)):
print t1[i] |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def dist(p1,p2):
return ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)**0.5
x=int(raw_input())
answers=[]
for i in range(x):
R=int(raw_input())
p1=[0]*2
p2=[0]*2
p3=[0]*2
p1=map(int,raw_input().split())
p2=map(int,raw_input().split())
p3=map(int,raw_input().split())
d1=dist(p1,p2)
d2=dist(p2,p3)
d3=dist(p1,p3)
if ((d1<=R and d2<=R) or (d1<R and d3<=R) or (d2<=R and d3<=R)):
answers.append('yes')
else:
answers.append('no')
for i in answers:
print i |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
for _ in xrange(input()):
dist = input()
ax, ay = map(int, raw_input().split())
bx, by = map(int, raw_input().split())
cx, cy = map(int, raw_input().split())
l = [math.sqrt((by - ay)**2 + (bx - ax)**2), math.sqrt((cy - by)**2 + (cx - bx)**2), math.sqrt((cy - ay)**2 + (cx - ax)**2)]
l1 = [c for c in l if c > dist]
if len(l1) > 1:
print "no"
if len(l1) == 0:
print "yes"
else:
sum1 = 0
for k in l:
if k not in l1:
sum1 += k
if sum1 >= l1[0]:
print "yes" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | #CODECHEF PROBLEM: COMM3
#AUTHOR: diksham1
t = int(raw_input())
while(t>0):
range = int(raw_input())
x1,y1 = map(float, raw_input().split())
x2,y2 = map(float, raw_input().split())
x3,y3 = map(float, raw_input().split())
ctr = 0;
if ((y2-y1)**2 + (x2-x1)**2)**0.5 <=range:
ctr += 1;
if ((y3-y1)**2 + (x3-x1)**2)**0.5 <=range:
ctr += 1;
if ((y2-y3)**2 + (x2-x3)**2)**0.5 <=range:
ctr += 1;
if ctr >=2:
print "yes"
else:
print "no"
t -= 1 |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def is_in_range(x1, y1, x2, y2, limit):
if((x1-x2)**2+(y1-y2)**2 <= limit**2):
return 1
else:
return 0
tc=int(raw_input())
for _ in range(tc):
limit=int(raw_input())
x1, y1=map(int, raw_input().split())
x2, y2=map(int, raw_input().split())
x3, y3=map(int, raw_input().split())
if(is_in_range(x1, y1, x2, y2,limit) + is_in_range(x1, y1, x3, y3, limit) + is_in_range(x2, y2, x3, y3, limit) > 1):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | n=int(raw_input())
import math
for _ in range(n):
d=int(raw_input())
x=[int(i) for i in raw_input().strip().split(' ')]
y=[int(i) for i in raw_input().strip().split(' ')]
z=[int(i) for i in raw_input().strip().split(' ')]
a=math.sqrt((x[0]-y[0])**2+(x[1]-y[1])**2)
b=math.sqrt((x[0]-z[0])**2+(x[1]-z[1])**2)
c=math.sqrt((z[0]-y[0])**2+(z[1]-y[1])**2)
if (a<=d and b<=d) or (a<=d and c<=d) or (c<=d and b<=d):
print 'yes'
else:
print 'no' |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | # @author Kilari Teja
# FLOW001
for Cycle in xrange(int(raw_input().strip())):
MaxRadiax = int(raw_input().strip())
Truss = False
ChefOrds = []
for Chefs in xrange(0, 3):
ChefOrds.append(map(int, raw_input().strip().split(" ")))
for Chef in ChefOrds:
Pair = 0
for Zerga in ChefOrds:
PointData = ((Zerga[0] - Chef[0])**2 + (Zerga[1] - Chef[1])**2)**0.5
if PointData <= MaxRadiax and PointData != 0:
Pair += 1
if Pair >= 2:
print "yes"
Truss = True
break
if not Truss:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | #Begineers Codechef 3way communication
t=input()
out=[]
for i in range (0, t):
r=input()
p=[]
A=raw_input()
B=raw_input()
C=raw_input()
a=A.split()
b=B.split()
c=C.split()
for i in range(0, 2):
a[i]=int(a[i])
b[i]=int(b[i])
c[i]=int(c[i])
p.append((((a[0]-b[0])**2)+((a[1]-b[1])**2))**(0.5))
p.append((((a[0]-c[0])**2)+((a[1]-c[1])**2))**(0.5))
p.append((((c[0]-b[0])**2)+((c[1]-b[1])**2))**(0.5))
count=0
#print p[0], p[1], p[2]
for i in range(0, 3):
if p[i]<=r:
count=count+1
#print count
if count>=2.0:
out.append("yes")
else:
out.append("no")
k=0
while k<t:
print out[k]
k=k+1 |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | T = int(raw_input())
for t in range (T):
R = int(raw_input())**2
a,b = map(int,raw_input().split())
c,d = map(int,raw_input().split())
x,y = map(int,raw_input().split())
d1 = (a-c)**2 + (b-d)**2
d2 = (c-x)**2 + (d-y)**2
d3 = (a-x)**2 + (b-y)**2
if d1<=R:
if d2<=R:
print "yes"
elif d3<=R:
print "yes"
else:
print "no"
elif d2<=R:
if d3<=R:
print "yes"
else:
print "no"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | #The Three Way Communications
from math import *
def dist(x1, x2, y1, y2):
d = sqrt((pow((x1 - x2), 2)) + (pow((y1 - y2), 2)))
return d
def leng(d1, d2, d3, n):
l = [d1, d2, d3]
l.sort()
if float(l[0]) <= n and float(l[1]) <= n and float(l[0]) + float(l[1]) >= l[2]:
return True
else:
return False
def main():
T = int(raw_input())
while(T!=0):
T-=1
n = int(raw_input())
x1, y1 = raw_input().split()
x2, y2 = raw_input().split()
x3, y3 = raw_input().split()
d1 = dist(int(x1), int(x2), int(y1), int(y2))
d2 = dist(int(x1), int(x3), int(y1), int(y3))
d3 = dist(int(x3), int(x2), int(y3), int(y2))
if leng(d1,d2,d3,n):
print 'yes'
else:
print 'no'
if __name__ == '__main__':
main() |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | T = int(raw_input())
for i in range(T):
R = int(raw_input())
p1 = map(int, raw_input().split())
p2 = map(int, raw_input().split())
p3 = map(int, raw_input().split())
count = 0
if ((p1[0]-p2[0])**2 + (p1[1] - p2[1])**2) > R**2:
count += 1
if ((p2[0]-p3[0])**2 + (p2[1] - p3[1])**2) > R**2:
count += 1
if ((p1[0]-p3[0])**2 + (p1[1] - p3[1])**2) > R**2:
count += 1
print "yes" if count <= 1 else "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | t = input()
while(t>0):
t-=1
r = input()
a=map(int,raw_input().split())
b=map(int,raw_input().split())
c=map(int,raw_input().split())
count=0
if( (a[0]-b[0])**2 +(a[1]-b[1])**2 <=r**2 ):
count+=1
if( (b[0]-c[0])**2 +(c[1]-b[1])**2 <=r**2):
count+=1
if( (c[0]-a[0])**2 +(c[1]-a[1])**2 <=r**2):
count+=1
if(count>=2):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
T=int(raw_input())
while T>0:
T-=1
R=int(raw_input())
x1,y1=map(int,raw_input().split())
x2,y2=map(int,raw_input().split())
x3,y3=map(int,raw_input().split())
dist_1=math.hypot(x2-x1,y2-y1)
dist_2=math.hypot(x3-x2,y3-y2)
dist_3=math.hypot(x3-x1,y3-y1)
if (dist_1 <=R and dist_2 <=R) or (dist_2<=R and dist_3<=R) or (dist_1<=R and dist_3<=R):
print "yes"
else:
print "no" |
comm3 | The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line transceivers which have a few advanced features. One is that even if two people cannot talk directly because they are out of range, if there is another transceiver that is close enough to both, then the two transceivers can still communicate with each other using the third transceiver as an intermediate device.
There has been a minor emergency in the Chef's restaurant
and he needs to communicate with both the head server and the sous-chef right away. Help the Chef determine if it is possible for all three people to communicate with each other, even if two must communicate through the third because they are too far apart.
Input
The first line contains a single positive integer T ≤ 100 indicating the number of test cases to follow. The first line of each test case contains a positive integer R ≤ 1,000 indicating that two transceivers can communicate directly without an intermediate transceiver if they are at most R meters away from each other. The remaining three lines of the test case describe the current locations of the Chef, the head server, and the sous-chef, respectively. Each such line contains two integers X,Y (at most 10,000 in absolute value) indicating that the respective person is located at position X,Y.
Output
For each test case you are to output a single line containing a single string. If it is possible for all three to communicate then you should output "yes". Otherwise, you should output "no".
To be clear, we say that two transceivers are close enough to communicate directly if the length of the straight line connecting their X,Y coordinates is at most R.
Example
Input:
3
1
0 1
0 0
1 0
2
0 1
0 0
1 0
2
0 0
0 2
2 1
Output:
yes
yes
no | {
"input": [
"3\n1\n0 1\n0 0\n1 0\n2\n0 1\n0 0\n1 0\n2\n0 0\n0 2\n2 1"
],
"output": [
"yes\nyes\nno\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def main():
t=int(raw_input())
while t :
t=t-1
r=int(raw_input())
z=[]
k=[]
for i in range(3):
x=raw_input().split()
x=map(int,x)
z.append(x)
r1=((z[0][0]-z[1][0])**2+(z[0][1]-z[1][1])**2)**0.5
r2=((z[1][0]-z[2][0])**2+(z[1][1]-z[2][1])**2)**0.5
r3=((z[0][0]-z[2][0])**2+(z[0][1]-z[2][1])**2)**0.5
k=[r1,r2,r3]
k=sorted(k)
if k[0]<=r and k[1]<=r :
print "yes"
else:
print "no"
if __name__=='__main__':
main() |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
while(b):
a,b=b,a%b
return a
t=input()
while(t):
a,b=map(int,raw_input().split())
print(gcd(a,b))
t=t-1; |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(a%b==0):
return b;
return gcd(b,a%b)
t = int(raw_input())
for i in range(t):
a = raw_input().split(" ")
print gcd(int(a[0]),int(a[1])) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
t=input()
for i in range (0,t):
a,b=map(int, raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
t = int(raw_input())
for i in range(t):
a,b = map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
while b:
a,b=b,a%b
return a
for i in range(int(raw_input())):
a,b=map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from fractions import gcd
t=input()
for i in xrange(t):
n1,n2=map(int,raw_input().split())
print gcd(n1,n2) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | ##Using the Eucledian Method to find gcd
t=input()
for i in range(t):
l=map(int,raw_input().split())
if l[0]>l[1]:
a,b=l[0],l[1]
else:
a,b=l[1],l[0]
while True:
if b==0:
print a
break
else:
r=a%b
a=b
b=r |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if (b==0):
return a
else:
return gcd(b,a%b)
test = int(raw_input())
for i in range(test):
a,b = map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from fractions import gcd
t=input()
while t:
a,b=map(int,raw_input().split())
print gcd(a,b)
t=t-1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
for i in range(int(raw_input())):
a,b=map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
for _ in range(input()):
m,n = map(int,raw_input().split())
print gcd(m,n) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b == 0):
return a
else:
return gcd(b,a%b)
for _ in range(int(input())):
a,b=map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import sys
def gcd(a,b):
if b == 0 :
return a
else:
return gcd(b,a%b)
try:
t=int(input())
for _ in xrange(t):
a,b = map(int,sys.stdin.readline().rstrip().split(' '))
print gcd(a,b)
except EOFError:
print("") |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from fractions import gcd
for i in xrange(input()):
a,b=map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a, b):
if min(a,b) == 0:
return max(a,b)
else:
if b > a:
return gcd(a, b%a)
else:
return gcd(b, a%b)
test_case = int(raw_input())
for t in range(test_case):
a, b = map(int, raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | for t in xrange(int(raw_input())):
a, b = map(int, raw_input().split())
while b:
a, b = b, a % b
print a |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b == 0:
return a
else:
return gcd(b, a % b)
t = int(raw_input())
for i in xrange(t):
li = map(int, raw_input().split())
print(gcd(li[0], li[1])) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
t=(int)(input())
for i in range(t):
a=map(int, raw_input().split())
print(gcd(a[0],a[1])) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | # your code goes here
def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
T = input()
for t in xrange(T):
val = raw_input().split(" ")
a = long(val[0])
b = long(val[1])
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b == 0:
return a
else:
return gcd(b,a%b)
T = int(raw_input())
while T :
a,b = map(int, raw_input().split())
print gcd(a,b)
T -= 1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
while b:
a,b=b,a%b
return a
t = input()
while t:
t=~(-t)
a,b=map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b) :
if b==0 :
return a
else :
return gcd(b,a%b)
t=int(input())
while t :
a,b=map(int,raw_input().split())
print gcd(a,b)
t-=1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(A,B):
if B == 0: return A
else: return gcd(B,A%B)
def GCD2():
t = int(raw_input())
while t:
A,B = map(int,raw_input().split())
print gcd(A,B); t-=1
if __name__ == '__main__': GCD2() |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | t=input()
def gcd(a,b):
if a==0:
return b
else:
return gcd(b%a,a)
for i in range(t):
l=[int(x) for x in raw_input().split()]
print gcd(l[0],l[1]) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b==0):
return a;
else:
return gcd(b,a%b)
t = input()
while t>0:
inp = raw_input().split()
a = (int)(inp[0])
b = (int)(inp[1])
ans = gcd(a,b)
print ans
t-=1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
while(b>0):
a,b=b,a%b
return a
T = int(raw_input())
for i in xrange(T):
a,b = map(int,raw_input().split())
print gcd(a,b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
t=int(input())
for i in range(0,t):
p,q=raw_input().split()
p=int(p)
q=int(q)
print gcd(p,q) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
t=input()
while t :
a,b =map(int,raw_input().split())
print(gcd(a,b))
t=t-1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd (a, b):
if b == 0:
return a
else:
return gcd (b, a % b)
t=int(raw_input())
while t:
a, b = map(int, raw_input().split())
print gcd(a,b)
t-=1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | t = int(raw_input())
def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b);
while(t):
x = raw_input()
x = x.split()
a = int(x[0])
b = int(x[1])
print gcd(a,b)
t = t-1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a, b):
if (b==0):
return a
else:
return gcd(b, a%b)
def main():
tc=input()
i=0
for i in range (0, tc):
string_input=raw_input()
input_list=string_input.split()
input_list=[int(a) for a in input_list]
print gcd(input_list[0], input_list[1])
main() |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def hcf(a,b):
if b==0:
return a;
else:
return hcf(b,a%b)
for i in range(int(raw_input())):
a=map(int,raw_input().split())
print hcf(a[0],a[1]) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import sys
def gcd(k,m):
while m!=0:
r = k % m
k = m
m = r
return k
n = input()
while n!=0:
a, b = [int(i) for i in sys.stdin.readline().strip().split()]
ans = gcd(a,b)
print ans
n = n-1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | from fractions import gcd
st = input()
for t in range(st):
a, b = map(int, raw_input().split())
print gcd(a, b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a, b):
if a == 0:
return b
else:
return gcd(b % a, a)
cases = int(raw_input())
for _dummy in range(cases):
a, b = map(int,raw_input().split())
print gcd(a, b) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | a = input()
def gcd(a,b):
if b == 0:
return a
else:
return gcd(b, a%b)
for b in range(a):
d = raw_input().split()
print gcd(int(d[0]), int(d[1])) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
ntc = int(raw_input())
while ntc!=0:
a,b = map(int,raw_input().split(" "))
print gcd(a,b)
ntc-=1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(x,y):
while True:
if y==0:
return x
r=x%y
if r==0:
return y
else:
x=y
y=r
n=input()
for i in range(0,n):
lis=list(raw_input().split())
n1=int(lis[0])
n2=int(lis[1])
print gcd(n2,n1) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import sys
#print "AMIT"
n=raw_input("")
def module(a2,b2):
if len(a2)<len(b2):
return a2
else:
c =int(a2)%int(b2)
c1=str(c)
return c1
def hcf(a,b):
a1=a
b1=b
b2=b
if b1=='0':
print a1
return
b1=module(a1,b1)
hcf(b2,b1)
i=0
while i<int(n):
a, b = raw_input("").split()
#tokenizedInput = sys.stdin.read().split()
#a, b = map(str, tokenizedInput[:2])
hcf(a,b)
i=i+1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
cases=int(raw_input())
for i in range(cases):
a,b=map(str,raw_input().split())
a=int(a);
ans=0;
if a==0:
print b
else:
for i in b:
ans=(ans*10 + int(i))%a
print gcd(a,ans) |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import sys
def GCD(A,B):
if B==0:
return A
else:
return GCD(B, A%B)
n= int(input())
while n>0:
A,B= map(int, sys.stdin.readline().split())
print GCD(A,B)
n-= 1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(at,bt):
if(bt==0):
return at;
else:
return gcd(bt,at%bt)
t = input()
# main
while t>0:
inp = raw_input().split()
a = (int)(inp[0])
b = (int)(inp[1])
ans = gcd(a,b)
print ans
t-=1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if(b==0):
return a
else:
return gcd(b,a%b)
def main():
t=input()
t1=t
lt=[]
while(t>0):
a,b=raw_input().split()
a,b=int(a),int(b)
x=gcd(a,b)
lt.append(x)
t=t-1
#print lt
for i in range(t1):
print lt[i]
if __name__ == '__main__':
main() |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | # cook your code here
def getModuloOf(a, two):
i=1;
b = int(two[:i]);
while(b<a and i<len(two)):
i=i+1;
b=int(two[:i]);
if(b<a or i==len(two)):
return b%a;
else:
rem=b%a;
s=str(rem)+two[i:];
return getModuloOf(a,s);
def findHCF(a, b):
if(a==0):
return b;
return findHCF(b%a,a);
t=int(raw_input());
#waste=raw_input();
while(t>0):
a,two = raw_input().split(' ');
a=int(a);
if(a==0):
print two;
else:
b=getModuloOf(a,two);
ans=findHCF(b,a);
print ans;
t=t-1; |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
t=input()
while t>0:
a,b = map(int, raw_input().split(" "))
print gcd(a,b)
t-=1 |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def gcd(a, b):
if(a == 0): return b;
return gcd(b % a, a);
t = input();
while(t > 0):
a, b = map(int, raw_input().split());
print gcd(a, b);
t -= 1; |
gcd2 | Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 digits.
Your task is to help Frank programming an efficient code for the challenge of Felman.
Input
The first line of the input file contains a number representing the number of lines to follow.
Each line consists of two number A and B (0 ≤ A ≤ 40000 and A ≤ B < 10^250).
Output
Print for each pair (A,B) in the input one integer representing the GCD of A and B.
Example
Input:
2
2 6
10 11
Output:
2
1 | {
"input": [
"2\n2 6\n10 11"
],
"output": [
"2\n1\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | import math
import sys
def parseIntList(str):
return [long(x) for x in str.split()]
def printBS(li):
if len(li) is 0:
print
else:
for i in range(len(li)-1):
print li[i],
print li[-1]
def gcd(a,b):
if b==0: return a
return gcd(b,a%b)
cases=input()
for case in range(cases):
b,a=raw_input().split()
b=int(b)
if b==0:
print a
else:
num=0
for i in a:
num=(num*10+int(i))%b
print gcd(b,num) |
luckybal | A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.
The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the number of digits 7 in the substring T[X, M]. For example, the string S = 7477447 is balanced since S[1, 4] = 7477 has 1 digit 4 and S[5, 7] = 447 has 1 digit 7. On the other hand, one can verify that the string S = 7 is not balanced.
The Little Elephant has the string S of the length N. He wants to know the number of such pairs of integers (L; R) that 1 ≤ L ≤ R ≤ N and the substring S[L, R] is balanced. Help him to find this number.
Notes.
Let S be some lucky string. Then
|S| denotes the length of the string S;
S[i] (1 ≤ i ≤ |S|) denotes the i^th character of S (the numeration of characters starts from 1);
S[L, R] (1 ≤ L ≤ R ≤ |S|) denotes the string with the following sequence of characters: S[L], S[L + 1], ..., S[R], and is called a substring of S. For L > R we mean by S[L, R] an empty string.
Input
The first line of the input file contains a single integer T, the number of test cases. Each of the following T lines contains one string, the string S for the corresponding test case. The input file does not contain any whitespaces.
Output
For each test case output a single line containing the answer for this test case.
Constraints
1 ≤ T ≤ 10
1 ≤ |S| ≤ 100000
S consists only of the lucky digits 4 and 7.
Example
Input:
4
47
74
477
4747477
Output:
2
2
3
23
Explanation
In the first test case balance substrings are S[1, 1] = 4 and S[1, 2] = 47.
In the second test case balance substrings are S[2, 2] = 4 and S[1, 2] = 74.
Unfortunately, we can't provide you with the explanations of the third and the fourth test cases. You should figure it out by yourself. Please, don't ask about this in comments. | {
"input": [
"4\n47\n74\n477\n4747477"
],
"output": [
"2\n2\n3\n23\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | n = input()
for i in range(n):
str = raw_input()
l = len(str)
megacounter = 0
counter = 0
i = 0
while(1):
while(i<l and str[i]=='7'):
i=i+1
counter=counter+1
if(i>=l):
break
megacounter = megacounter + (counter*(counter+1))/2
i=i+1
counter=0
megacounter = megacounter + (counter*(counter+1))/2
supercounter = (l*(l+1))/2 - megacounter
print supercounter |
luckybal | A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.
The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the number of digits 7 in the substring T[X, M]. For example, the string S = 7477447 is balanced since S[1, 4] = 7477 has 1 digit 4 and S[5, 7] = 447 has 1 digit 7. On the other hand, one can verify that the string S = 7 is not balanced.
The Little Elephant has the string S of the length N. He wants to know the number of such pairs of integers (L; R) that 1 ≤ L ≤ R ≤ N and the substring S[L, R] is balanced. Help him to find this number.
Notes.
Let S be some lucky string. Then
|S| denotes the length of the string S;
S[i] (1 ≤ i ≤ |S|) denotes the i^th character of S (the numeration of characters starts from 1);
S[L, R] (1 ≤ L ≤ R ≤ |S|) denotes the string with the following sequence of characters: S[L], S[L + 1], ..., S[R], and is called a substring of S. For L > R we mean by S[L, R] an empty string.
Input
The first line of the input file contains a single integer T, the number of test cases. Each of the following T lines contains one string, the string S for the corresponding test case. The input file does not contain any whitespaces.
Output
For each test case output a single line containing the answer for this test case.
Constraints
1 ≤ T ≤ 10
1 ≤ |S| ≤ 100000
S consists only of the lucky digits 4 and 7.
Example
Input:
4
47
74
477
4747477
Output:
2
2
3
23
Explanation
In the first test case balance substrings are S[1, 1] = 4 and S[1, 2] = 47.
In the second test case balance substrings are S[2, 2] = 4 and S[1, 2] = 74.
Unfortunately, we can't provide you with the explanations of the third and the fourth test cases. You should figure it out by yourself. Please, don't ask about this in comments. | {
"input": [
"4\n47\n74\n477\n4747477"
],
"output": [
"2\n2\n3\n23\n"
]
} | {
"input": [],
"output": []
} | CORRECT | python2 | def calc(str):
length = len(str)
prev_four = -1
count = 0
for i in range(0,length):
if str[i] == "4":
count+=(i-prev_four)*(length-i)
prev_four = i
return count
t = int(raw_input())
for i in range(0,t):
str = raw_input()
print calc(str) |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 335