message stringlengths 2 44.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 276 109k | cluster float64 23 23 | __index_level_0__ int64 552 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.
Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 β€ x β€ x_2 and y_1 β€ y β€ y_2, where (x_1, y_1) and (x_2, y_2) are coordinates of the left bottom and the right top corners of the rectangle being photographed. The area of this rectangle can be zero.
After taking the photo, Pavel wrote down coordinates of n of his favourite stars which appeared in the photo. These points are not necessarily distinct, there can be multiple stars in the same point of the sky.
Pavel has lost his camera recently and wants to buy a similar one. Specifically, he wants to know the dimensions of the photo he took earlier. Unfortunately, the photo is also lost. His notes are also of not much help; numbers are written in random order all over his notepad, so it's impossible to tell which numbers specify coordinates of which points.
Pavel asked you to help him to determine what are the possible dimensions of the photo according to his notes. As there are multiple possible answers, find the dimensions with the minimal possible area of the rectangle.
Input
The first line of the input contains an only integer n (1 β€ n β€ 100 000), the number of points in Pavel's records.
The second line contains 2 β
n integers a_1, a_2, ..., a_{2 β
n} (1 β€ a_i β€ 10^9), coordinates, written by Pavel in some order.
Output
Print the only integer, the minimal area of the rectangle which could have contained all points from Pavel's records.
Examples
Input
4
4 1 3 2 3 2 1 3
Output
1
Input
3
5 8 5 5 7 5
Output
0
Note
In the first sample stars in Pavel's records can be (1, 3), (1, 3), (2, 3), (2, 4). In this case, the minimal area of the rectangle, which contains all these points is 1 (rectangle with corners at (1, 3) and (2, 4)).
Submitted Solution:
```
n=int(input())-1
s=sorted(map(int,input().split()))
print((s[n]-s[0])*(s[2*n+1]-s[n+1]))
``` | instruction | 0 | 89,263 | 23 | 178,526 |
No | output | 1 | 89,263 | 23 | 178,527 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.
Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 β€ x β€ x_2 and y_1 β€ y β€ y_2, where (x_1, y_1) and (x_2, y_2) are coordinates of the left bottom and the right top corners of the rectangle being photographed. The area of this rectangle can be zero.
After taking the photo, Pavel wrote down coordinates of n of his favourite stars which appeared in the photo. These points are not necessarily distinct, there can be multiple stars in the same point of the sky.
Pavel has lost his camera recently and wants to buy a similar one. Specifically, he wants to know the dimensions of the photo he took earlier. Unfortunately, the photo is also lost. His notes are also of not much help; numbers are written in random order all over his notepad, so it's impossible to tell which numbers specify coordinates of which points.
Pavel asked you to help him to determine what are the possible dimensions of the photo according to his notes. As there are multiple possible answers, find the dimensions with the minimal possible area of the rectangle.
Input
The first line of the input contains an only integer n (1 β€ n β€ 100 000), the number of points in Pavel's records.
The second line contains 2 β
n integers a_1, a_2, ..., a_{2 β
n} (1 β€ a_i β€ 10^9), coordinates, written by Pavel in some order.
Output
Print the only integer, the minimal area of the rectangle which could have contained all points from Pavel's records.
Examples
Input
4
4 1 3 2 3 2 1 3
Output
1
Input
3
5 8 5 5 7 5
Output
0
Note
In the first sample stars in Pavel's records can be (1, 3), (1, 3), (2, 3), (2, 4). In this case, the minimal area of the rectangle, which contains all these points is 1 (rectangle with corners at (1, 3) and (2, 4)).
Submitted Solution:
```
n= int(input())
l = list(map(int,input().split()))
l.sort()
print((l[n-1]-l[0])*(l[-1]-l[n]))
``` | instruction | 0 | 89,264 | 23 | 178,528 |
No | output | 1 | 89,264 | 23 | 178,529 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.
Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 β€ x β€ x_2 and y_1 β€ y β€ y_2, where (x_1, y_1) and (x_2, y_2) are coordinates of the left bottom and the right top corners of the rectangle being photographed. The area of this rectangle can be zero.
After taking the photo, Pavel wrote down coordinates of n of his favourite stars which appeared in the photo. These points are not necessarily distinct, there can be multiple stars in the same point of the sky.
Pavel has lost his camera recently and wants to buy a similar one. Specifically, he wants to know the dimensions of the photo he took earlier. Unfortunately, the photo is also lost. His notes are also of not much help; numbers are written in random order all over his notepad, so it's impossible to tell which numbers specify coordinates of which points.
Pavel asked you to help him to determine what are the possible dimensions of the photo according to his notes. As there are multiple possible answers, find the dimensions with the minimal possible area of the rectangle.
Input
The first line of the input contains an only integer n (1 β€ n β€ 100 000), the number of points in Pavel's records.
The second line contains 2 β
n integers a_1, a_2, ..., a_{2 β
n} (1 β€ a_i β€ 10^9), coordinates, written by Pavel in some order.
Output
Print the only integer, the minimal area of the rectangle which could have contained all points from Pavel's records.
Examples
Input
4
4 1 3 2 3 2 1 3
Output
1
Input
3
5 8 5 5 7 5
Output
0
Note
In the first sample stars in Pavel's records can be (1, 3), (1, 3), (2, 3), (2, 4). In this case, the minimal area of the rectangle, which contains all these points is 1 (rectangle with corners at (1, 3) and (2, 4)).
Submitted Solution:
```
n = int(input())
m=list(map(int,input().split()))
m.sort()
n*=2
#print(m)
print((m[n//2-1]-m[0])*(m[n-1]-m[n//2]))
``` | instruction | 0 | 89,265 | 23 | 178,530 |
No | output | 1 | 89,265 | 23 | 178,531 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,300 | 23 | 178,600 |
Tags: binary search, geometry, math
Correct Solution:
```
import math
n,r=input().split()
n=int(n)
r=float(r)
deg=math.radians(360/n)
R=(math.sqrt(1-math.cos(deg))*r)/(math.sqrt(2)-math.sqrt(1-math.cos(deg)))
print(R)
``` | output | 1 | 89,300 | 23 | 178,601 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,301 | 23 | 178,602 |
Tags: binary search, geometry, math
Correct Solution:
```
''' Geometry & Math! '''
import math
In = input().split()
n = float(In[0])
r = float(In[1])
n = 360 / n;
deg = n/2;
deg = math.sin( deg * (math.pi/180.0))
R = (deg*r) / (1 - deg)
print(R)
``` | output | 1 | 89,301 | 23 | 178,603 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,302 | 23 | 178,604 |
Tags: binary search, geometry, math
Correct Solution:
```
import sys
from math import sin, pi
readline = sys.stdin.readline
N, r = map(int, readline().split())
theta = pi/N
ok = 10**10
ng = 0
for _ in range(100000):
med = (ok+ng)/2
if (1/sin(theta)-1)*med > r:
ok = med
else:
ng = med
print(ok)
``` | output | 1 | 89,302 | 23 | 178,605 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,303 | 23 | 178,606 |
Tags: binary search, geometry, math
Correct Solution:
```
import math
n,r = [int(x) for x in input().split()]
x = math.sin(math.pi/n)
y = (x*r)/(1-x)
print(y)
``` | output | 1 | 89,303 | 23 | 178,607 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,304 | 23 | 178,608 |
Tags: binary search, geometry, math
Correct Solution:
```
import math
s=list(map(int,input().split()))
n,r=s[0],s[1]
pi=math.radians(180/n)
x=math.sin(pi)
ans=(x*r)/(1-x)
print(ans)
``` | output | 1 | 89,304 | 23 | 178,609 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,305 | 23 | 178,610 |
Tags: binary search, geometry, math
Correct Solution:
```
from math import *
n,r=map(int,input().split())
d=radians(360/(2*n))
k=sin(d)
print(r*k/(1-k))
``` | output | 1 | 89,305 | 23 | 178,611 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,306 | 23 | 178,612 |
Tags: binary search, geometry, math
Correct Solution:
```
import math
x,y = map(int,input().split())
o = math.sin(math.pi/x)
ans = y*o/(1-o)
print(ans)
``` | output | 1 | 89,306 | 23 | 178,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391 | instruction | 0 | 89,307 | 23 | 178,614 |
Tags: binary search, geometry, math
Correct Solution:
```
import math
n, r = (int(i) for i in input().strip().split())
f = math.sin(math.radians(360/(2*n)))
print(r*f/(1-f))
``` | output | 1 | 89,307 | 23 | 178,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
import math
inp = input().split()
n = float(inp[0])
r = float(inp[1])
print(r*math.sin(math.pi/n)/(1 - math.sin(math.pi/n)))
``` | instruction | 0 | 89,308 | 23 | 178,616 |
Yes | output | 1 | 89,308 | 23 | 178,617 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
import math
pi=22/7
n,r=list(map(int,input().split()))
angle=(2*math.pi)/n
angle=angle/2
value=r*(math.sin(angle))/(1-math.sin(angle))
print(round(value,7))
``` | instruction | 0 | 89,309 | 23 | 178,618 |
Yes | output | 1 | 89,309 | 23 | 178,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
import math
n,r=[int(x) for x in input().split()]
a=math.cos((3.141592653589793*(n-2)/n)/2)
print((a*r)/(1-a))
``` | instruction | 0 | 89,310 | 23 | 178,620 |
Yes | output | 1 | 89,310 | 23 | 178,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
import math
n, r = map(int, input().split())
print("%.7f" % ((r * math.cos((math.pi * (n - 2)) / (2 * n))) / (1 - math.cos((math.pi * (n - 2)) / (2 * n)))))
``` | instruction | 0 | 89,311 | 23 | 178,622 |
Yes | output | 1 | 89,311 | 23 | 178,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
from os import path
import sys,time
# mod = int(1e9 + 7)
# import re
from math import ceil, floor,gcd,log,log2 ,factorial,cos,sin,pi
from collections import defaultdict ,Counter , OrderedDict , deque
# from itertools import combinations
from string import ascii_lowercase ,ascii_uppercase
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
#----------------------------INPUT FUNCTIONS------------------------------------------#
I = lambda :int(sys.stdin.buffer.readline())
tup= lambda : map(int , sys.stdin.buffer.readline().split())
lint = lambda :[int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda: sys.stdin.readline().strip('\n')
grid = lambda r :[lint() for i in range(r)]
stpr = lambda x : sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if (path.exists('input.txt')):
sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
#left shift --- num*(2**k) --(k - shift)
# input = sys.stdin.readline
n , R = tup()
theta = cos((2*pi) / n)
# a**2 = b**2 + c**2 - 2*b.c.cos A
lo = 0
hi = 10**9
m = maxx
d = defaultdict(int)
while lo <= hi:
r = (lo+hi)/2
x = (2*r)**2
y = (1 - theta)*(2*((R+r)**2))
if x-y == 0:
break
elif x - y < 0 :
lo = r - 1
ans = r
else:
hi = r + 1
d[r]+=1
if d[r] > 1:
break
print(r)
if localsys:
print("\n\nTime Elased :",time.time() - start_time,"seconds")
``` | instruction | 0 | 89,312 | 23 | 178,624 |
No | output | 1 | 89,312 | 23 | 178,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
#
import math
n,m=map(int, input().split())
r=float(m)
pi=3.14159265359
print("sin - ", math.sin(pi/float(n)))
res= ( r * math.sin(pi/float(n)) ) / ( 1 - math.sin(pi/float(n)) )
print(res)
``` | instruction | 0 | 89,313 | 23 | 178,626 |
No | output | 1 | 89,313 | 23 | 178,627 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
from math import pi, sin
k,r = map(int,input().split())
print(r*(1/sin(pi/k)-1))
``` | instruction | 0 | 89,314 | 23 | 178,628 |
No | output | 1 | 89,314 | 23 | 178,629 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
NN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles:
<image>
It turned out that the circles are equal. NN was very surprised by this fact, so he decided to create a similar picture himself.
He managed to calculate the number of outer circles n and the radius of the inner circle r. NN thinks that, using this information, you can exactly determine the radius of the outer circles R so that the inner circle touches all of the outer ones externally and each pair of neighboring outer circles also touches each other. While NN tried very hard to guess the required radius, he didn't manage to do that.
Help NN find the required radius for building the required picture.
Input
The first and the only line of the input file contains two numbers n and r (3 β€ n β€ 100, 1 β€ r β€ 100) β the number of the outer circles and the radius of the inner circle respectively.
Output
Output a single number R β the radius of the outer circle required for building the required picture.
Your answer will be accepted if its relative or absolute error does not exceed 10^{-6}.
Formally, if your answer is a and the jury's answer is b. Your answer is accepted if and only when (|a-b|)/(max(1, |b|)) β€ 10^{-6}.
Examples
Input
3 1
Output
6.4641016
Input
6 1
Output
1.0000000
Input
100 100
Output
3.2429391
Submitted Solution:
```
# your code goes here
import math
n,r=map(int,input().split())
cs=math.cos(math.pi/n)
print(r*cs/(1-cs))
``` | instruction | 0 | 89,315 | 23 | 178,630 |
No | output | 1 | 89,315 | 23 | 178,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,439 | 23 | 178,878 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
MOD = 10 ** 9 + 7
RLIMIT = 1000
DEBUG = 1
def main():
for _ in inputt():
n, = inputi()
d = 2 * pi / (n * 2)
s = 0
for i in range(1, 2 * n + 1):
if sin(i * d + pi / 4) > 0:
s += sin(i * d + pi / 4)
print(s)
# region M
# region import
from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict, deque
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(RLIMIT)
# endregion
# region fastio
BUFSIZE = 8192
class FastIO(io.IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = io.BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(io.IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
if args:
sys.stdout.write(str(args[0]))
split = kwargs.pop("split", " ")
for arg in args[1:]:
sys.stdout.write(split)
sys.stdout.write(str(arg))
sys.stdout.write(kwargs.pop("end", "\n"))
def debug(*args, **kwargs):
if DEBUG and not __debug__:
print("debug", *args, **kwargs)
sys.stdout.flush()
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip()
inputt = lambda t = 0: range(t) if t else range(int(input()))
inputs = lambda: input().split()
inputi = lambda k = int: map(k, inputs())
inputl = lambda t = 0, k = lambda: list(inputi()): [k() for _ in range(t)] if t else list(k())
# endregion
# region bisect
def len(a):
if isinstance(a, range):
return -((a.start - a.stop) // a.step)
return builtins.len(a)
def bisect_left(a, x, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
if key == None: key = do_nothing
while lo < hi:
mid = (lo + hi) // 2
if key(a[mid]) < x: lo = mid + 1
else: hi = mid
return lo
def bisect_right(a, x, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
if key == None: key = do_nothing
while lo < hi:
mid = (lo + hi) // 2
if x < key(a[mid]): hi = mid
else: lo = mid + 1
return lo
def insort_left(a, x, key = None, lo = 0, hi = None):
lo = bisect_left(a, x, key, lo, hi)
a.insert(lo, x)
def insort_right(a, x, key = None, lo = 0, hi = None):
lo = bisect_right(a, x, key, lo, hi)
a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right
def index(a, x, default = None, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
if key == None: key = do_nothing
i = bisect_left(a, x, key, lo, hi)
if lo <= i < hi and key(a[i]) == x: return a[i]
if default != None: return default
raise ValueError
def find_lt(a, x, default = None, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
i = bisect_left(a, x, key, lo, hi)
if lo < i <= hi: return a[i - 1]
if default != None: return default
raise ValueError
def find_le(a, x, default = None, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
i = bisect_right(a, x, key, lo, hi)
if lo < i <= hi: return a[i - 1]
if default != None: return default
raise ValueError
def find_gt(a, x, default = None, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
i = bisect_right(a, x, key, lo, hi)
if lo <= i < hi: return a[i]
if default != None: return default
raise ValueError
def find_ge(a, x, default = None, key = None, lo = 0, hi = None):
if lo < 0: lo = 0
if hi == None: hi = len(a)
i = bisect_left(a, x, key, lo, hi)
if lo <= i < hi: return a[i]
if default != None: return default
raise ValueError
# endregion
# region csgraph
# TODO
class Tree:
def __init__(n):
self._n = n
self._conn = [[] for _ in range(n)]
self._list = [0] * n
def connect(a, b):
pass
# endregion
# region ntheory
class Sieve:
def __init__(self):
self._n = 6
self._list = [2, 3, 5, 7, 11, 13]
def extend(self, n):
if n <= self._list[-1]: return
maxbase = int(n ** 0.5) + 1
self.extend(maxbase)
begin = self._list[-1] + 1
newsieve = [i for i in range(begin, n + 1)]
for p in self.primerange(2, maxbase):
for i in range(-begin % p, len(newsieve), p):
newsieve[i] = 0
self._list.extend([x for x in newsieve if x])
def extend_to_no(self, i):
while len(self._list) < i:
self.extend(int(self._list[-1] * 1.5))
def primerange(self, a, b):
a = max(2, a)
if a >= b: return
self.extend(b)
i = self.search(a)[1]
maxi = len(self._list) + 1
while i < maxi:
p = self._list[i - 1]
if p < b:
yield p
i += 1
else: return
def search(self, n):
if n < 2: raise ValueError
if n > self._list[-1]: self.extend(n)
b = bisect(self._list, n)
if self._list[b - 1] == n: return b, b
else: return b, b + 1
def __contains__(self, n):
if n < 2: raise ValueError
if not n % 2: return n == 2
a, b = self.search(n)
return a == b
def __getitem__(self, n):
if isinstance(n, slice):
if n.stop:
self.extend_to_no(n.stop + 1)
return self._list[n.start: n.stop: n.step]
return islice(self, n.start, n.stop, n.step)
else:
self.extend_to_no(n + 1)
return self._list[n]
sieve = Sieve()
def isprime(n):
if n <= sieve._list[-1]:
return n in sieve
for i in sieve:
if not n % i: return False
if n < i * i: return True
prime = sieve.__getitem__
primerange = lambda a, b = 0: sieve.primerange(a, b) if b else sieve.primerange(2, a)
def factorint(n):
factors = []
for i in sieve:
if n < i * i: break
while not n % i:
factors.append(i)
n //= i
if n != 1: factors.append(n)
return factors
factordict = lambda n: Counter(factorint(n))
# endregion
# region main
if __name__ == "__main__":
main()
# endregion
# endregion
``` | output | 1 | 89,439 | 23 | 178,879 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,440 | 23 | 178,880 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
import sys
import math
#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')
from sys import stdin, stdout
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
print(1 / math.tan(math.pi / (2 * n)))
``` | output | 1 | 89,440 | 23 | 178,881 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,441 | 23 | 178,882 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
from math import radians,tan
t = int(input())
for _ in range(t):
n = int(input())
alpha = radians(90/n)
h = 0.5/(tan(alpha))
print(2*h)
``` | output | 1 | 89,441 | 23 | 178,883 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,442 | 23 | 178,884 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
import sys
import math
pi=math.pi
q=int(input())
for i in range(q):
a=int(sys.stdin.readline())
if a//2%2==0:
n1=a//2+1
else:
n1=a//2
n2=(a-n1)
rad=1/(2*math.sin(pi/(2*a)))
b=pow(2*rad*rad-2*rad*rad*math.cos(2*pi/(2*a)*n1),1/2)/pow(2,1/2)
c=pow(2*rad*rad-2*rad*rad*math.cos(2*pi/(2*a)*n2),1/2)/pow(2,1/2)
print(b+c)
'''
1/(2*math.sin(pi/(2*a)))
print( )
print(1/math.tan(pi/(2*a)))
'''
``` | output | 1 | 89,442 | 23 | 178,885 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,443 | 23 | 178,886 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
from sys import stdin, stdout
import math
def main():
# t = 1
t = int(input())
for i in range(t):
n = int(input())
n *= 2
a = 1
big_r = a / (2 * math.tan(math.pi / n))
print(big_r * 2)
main()
``` | output | 1 | 89,443 | 23 | 178,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,444 | 23 | 178,888 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
from math import sin, pi, sqrt
test=int(input())
answer=[]
for test_case in range(test):
n=2*int(input())
sine=sin(pi/180* (180-360/n)/2)
answer.append( str(sine/sqrt(1-sine**2)) )
print(("\n").join(answer))
``` | output | 1 | 89,444 | 23 | 178,889 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,445 | 23 | 178,890 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
import math
t = int(input())
for i in range(t):
n = int(input()) * 2
rad = 1 / math.sqrt(2 * (1 - math.cos(2 * math.pi / n)));
area = 0.5 * math.sin(2 * math.pi / n) * rad * rad
h = 2 * area
print(2 * h)
``` | output | 1 | 89,445 | 23 | 178,891 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469 | instruction | 0 | 89,446 | 23 | 178,892 |
Tags: binary search, geometry, math, ternary search
Correct Solution:
```
from decimal import Decimal
import math
for ii in range(int(input())):
n = int(input())
print(1/(math.tan(math.pi/(2*n))))
``` | output | 1 | 89,446 | 23 | 178,893 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
import math
t = int(input())
for i in range(t):
n = int(input())
n *= 2
ans = math.cos(math.pi / n)/math.sin(math.pi/n)
print(ans)
``` | instruction | 0 | 89,447 | 23 | 178,894 |
Yes | output | 1 | 89,447 | 23 | 178,895 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
# Anuneet Anand
import math
T = int(input())
while T:
n = int(input())
m = 2*n
a = 180/(m)
x = 1/math.tan(math.radians(a))
print(x)
T = T - 1
``` | instruction | 0 | 89,448 | 23 | 178,896 |
Yes | output | 1 | 89,448 | 23 | 178,897 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
t = int(input())
import math
for _ in range(t):
s = float(input())
a = math.pi/(2.0*s)
p = min(1/math.tan(a), 1/math.sin(a))
print(p)
``` | instruction | 0 | 89,449 | 23 | 178,898 |
Yes | output | 1 | 89,449 | 23 | 178,899 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
import math
def rn():
a = int(input())
return a
def rl():
a = list(map(int, input().split()))
return a
for _ in range(int(input())):
n = rn()
n = 2*n
ang1 = math.pi/n
hyp = 1/(2*math.sin(ang1))
base = 1/2
perp = math.sqrt(hyp**2-base**2)
print(2*perp)
``` | instruction | 0 | 89,450 | 23 | 178,900 |
Yes | output | 1 | 89,450 | 23 | 178,901 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
import math
for _ in range(int(input())):
n = int(input())
if n == 2:
print(1)
elif n == 4:
print(2.414213562)
else:
r = 1/(2*math.sin(math.radians(180/(2*n))))
print(r*2)
``` | instruction | 0 | 89,451 | 23 | 178,902 |
No | output | 1 | 89,451 | 23 | 178,903 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
import sys, math,os
from io import BytesIO, IOBase
from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7
def main():
for t in range(int(data())):
n=int(data())
if n%2==0:
print(1/math.tan(((90/n)*math.pi)/180))
else:
print(1/math.cos(((90/n)*math.pi)/180))
if __name__ == '__main__':
main()
``` | instruction | 0 | 89,452 | 23 | 178,904 |
No | output | 1 | 89,452 | 23 | 178,905 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
import math
for _ in range(int(input())):
n=int(input())
p=math.pi
r=0.5/(math.sin(p/(2*n)))
an1=n//2*(p/n)
an2=p-an1
print(r,an1,an2)
b=(r*math.sin(an1/2))*(2**0.5)
c=(r*math.sin(an2/2))*(2**0.5)
print(b+c)
``` | instruction | 0 | 89,453 | 23 | 178,906 |
No | output | 1 | 89,453 | 23 | 178,907 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The statement of this problem is the same as the statement of problem C2. The only difference is that, in problem C1, n is always even, and in C2, n is always odd.
You are given a regular polygon with 2 β
n vertices (it's convex and has equal sides and equal angles) and all its sides have length 1. Let's name it as 2n-gon.
Your task is to find the square of the minimum size such that you can embed 2n-gon in the square. Embedding 2n-gon in the square means that you need to place 2n-gon in the square in such way that each point which lies inside or on a border of 2n-gon should also lie inside or on a border of the square.
You can rotate 2n-gon and/or the square.
Input
The first line contains a single integer T (1 β€ T β€ 200) β the number of test cases.
Next T lines contain descriptions of test cases β one per line. Each line contains single even integer n (2 β€ n β€ 200). Don't forget you need to embed 2n-gon, not an n-gon.
Output
Print T real numbers β one per test case. For each test case, print the minimum length of a side of the square 2n-gon can be embedded in. Your answer will be considered correct if its absolute or relative error doesn't exceed 10^{-6}.
Example
Input
3
2
4
200
Output
1.000000000
2.414213562
127.321336469
Submitted Solution:
```
import math
for _ in range(int(input())):
n = 2*int(input())
#print(1+2*((n-4)/4)*(math.sin(((n-2)*(math.pi)/n)-(math.pi/2))))
print(1/(math.sin(math.pi/(n))))
``` | instruction | 0 | 89,454 | 23 | 178,908 |
No | output | 1 | 89,454 | 23 | 178,909 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,696 | 23 | 179,392 |
Tags: combinatorics, implementation, math
Correct Solution:
```
def f(a,b,c,l):
if a<b+c:
return 0
else:
c=min(l,a-b-c)
return (c+1)*(c+2)/2
a,b,c,l = map(int,input().split())
z=(l+1)*(l+2)*(l+3)/6
i=0
while i<=l:
z-=f(a+i,b,c,l-i)+f(b+i,c,a,l-i)+f(c+i,a,b,l-i)
i+=1
print(int(z))
``` | output | 1 | 89,696 | 23 | 179,393 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,697 | 23 | 179,394 |
Tags: combinatorics, implementation, math
Correct Solution:
```
a, b, c, l = map(int, input().split())
cnt = (l + 3) * (l + 2) * (l + 1) // 3
for i in (a, b, c):
s = 2 * i - a - b - c
for x in range(max(0, -s), l + 1):
m = min(s + x, l - x)
cnt -= (m + 1) * (m + 2)
print(cnt // 2)
``` | output | 1 | 89,697 | 23 | 179,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,698 | 23 | 179,396 |
Tags: combinatorics, implementation, math
Correct Solution:
```
a, b, c, d = map(int, input().split(' '))
ans = -(d+1) * (d+2) * (d+3) // 6
for l1 in range(0, d+1):
minx = min(d-l1, a-b-c+l1)
if minx < 0:
continue;
else:
ans += (minx + 1) * (minx + 2) // 2
a, b, c = b, c, a
for l1 in range(0, d+1):
minx = min(d-l1, a-b-c+l1)
if minx < 0:
continue;
else:
ans += (minx + 1) * (minx + 2) // 2
a, b, c = b, c, a
for l1 in range(0, d+1):
minx = min(d-l1, a-b-c+l1)
if minx < 0:
continue;
else:
ans += (minx + 1) * (minx + 2) // 2
print(-ans)
``` | output | 1 | 89,698 | 23 | 179,397 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,699 | 23 | 179,398 |
Tags: combinatorics, implementation, math
Correct Solution:
```
__author__ = 'nobik'
def count(a, b, c, x):
if (a < b + c):
return 0
value = min(x, a - b - c)
return (value + 1) * (value + 2) // 2
a, b, c, l = map(int, input().split())
ans = (l + 1) * (l + 2) * (l + 3) // 6
for i in range(l + 1):
ans -= count(a + i, b, c, l - i)
ans -= count(b + i, a, c, l - i)
ans -= count(c + i, a, b, l - i)
print(ans)
``` | output | 1 | 89,699 | 23 | 179,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,700 | 23 | 179,400 |
Tags: combinatorics, implementation, math
Correct Solution:
```
'''
import sys
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
'''
def Solve(a, b, c, l):
delta = a - b - c
if delta < 0:
return 0
k = min(l, delta) + 1
return k * (k + 1) // 2
a, b, c, l = map(int, input().split())
ans = (l + 3) * (l + 2) * (l + 1) // 6
for d in range(l + 1):
ans -= Solve(a + d, b, c, l - d) + Solve(b + d, a, c, l - d) + Solve(c + d, a, b, l - d)
print(ans)
``` | output | 1 | 89,700 | 23 | 179,401 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,701 | 23 | 179,402 |
Tags: combinatorics, implementation, math
Correct Solution:
```
a, b, c, l = map(int, input().split())
ans = (l + 3) * (l + 2) * (l + 1) // 3
for z in (a, b, c):
s = 2 * z - a - b - c
for x in range(max(0, -s), l + 1):
m = min(s + x, l - x)
ans -= (m + 1) * (m + 2)
print(ans // 2)
``` | output | 1 | 89,701 | 23 | 179,403 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,702 | 23 | 179,404 |
Tags: combinatorics, implementation, math
Correct Solution:
```
def solve(a, b, c):
ans = 0
for da in range(max(0, b + c - a), l + 1):
x = min(a - b - c + da, l - da)
ans += (x + 1) * (x + 2) // 2
return ans
a, b, c, l = map(int, input().split())
print((l + 1) * (l + 2) * (l + 3) // 6 - solve(a, b, c) - solve(b, a, c) - solve(c, a, b))
``` | output | 1 | 89,702 | 23 | 179,405 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions. | instruction | 0 | 89,703 | 23 | 179,406 |
Tags: combinatorics, implementation, math
Correct Solution:
```
p = list(map(int, input().split()))
l = p.pop()
n = (l + 1) * (l + 2) * (l + 3) // 6
s = sum(p)
for q in p:
t = 2 * q - s
for d in range(l + 1):
k = min(t + d, l - d) + 1
if k > 0: n -= k * k + k >> 1
print(n)
``` | output | 1 | 89,703 | 23 | 179,407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
a, b, c, l = map(int, input().split())
ans = (l + 3) * (l + 2) * (l + 1) // 3
for z in (a, b, c):
s = 2 * z - a - b - c
for x in range(max(0, -s), l + 1):
m = min(s + x, l - x)
ans -= (m + 1) * (m + 2)
print(ans // 2)
# Made By Mostafa_Khaled
``` | instruction | 0 | 89,704 | 23 | 179,408 |
Yes | output | 1 | 89,704 | 23 | 179,409 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
#in the name of god
#Mr_Rubick
a,b,c,l=map(int, input().split())
cnt=(l+3)*(l+2)*(l+1)//3
for i in (a,b,c):
s=2*i-a-b-c
for x in range(max(0,-s),l+1):
m = min(s+x,l-x)
cnt-=(m+1)*(m+2)
print(cnt//2)
``` | instruction | 0 | 89,705 | 23 | 179,410 |
Yes | output | 1 | 89,705 | 23 | 179,411 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
a, b, c, l = map(int, input().split())
ans = (l + 3) * (l + 2) // 2 * (l + 1) // 3
for z in (a, b, c):
s = 2 * z - a - b - c
for x in range(l + 1):
m = min(s + x, l - x)
if m >= 0:
ans -= (m + 1) * (m + 2) >> 1
print(ans)
``` | instruction | 0 | 89,706 | 23 | 179,412 |
Yes | output | 1 | 89,706 | 23 | 179,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
def f(a, b, c, l):
k = min(l, a - b - c)
return 0 if a < b + c else (k + 1) * (k + 2) // 2
solve = lambda i: f(a + i, b, c, l - i) + f(b + i, c, a, l - i) + f(c + i, a, b, l - i)
a, b, c, l = map(int, input().split())
ans = (l + 1) * (l + 2) * (l + 3) // 6 - sum(solve(i) for i in range(l + 1))
print(ans)
``` | instruction | 0 | 89,707 | 23 | 179,414 |
Yes | output | 1 | 89,707 | 23 | 179,415 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
a, b, c, l = map(int, input().split())
ans = (l + 3) * (l + 2) * (l + 1) // 3
for z in (a, b, c):
s = 2 * z - a - b - c
for x in range(max(0, -s), (l - s) // 2 + 1):
m = s + x
ans -= (m + 1) * (m + 2)
for x in range((l - s) // 2 + 1, l + 1):
m = l - x
ans -= (m + 1) * (m + 2)
print(ans // 2)
``` | instruction | 0 | 89,708 | 23 | 179,416 |
No | output | 1 | 89,708 | 23 | 179,417 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
def f(a,b,c,l):
if a<b+c:
return 0
else:
c=min(l,a-b-c)
return (c+1)*(c+2)/2
a,b,c,l = map(int,input().split())
z=(l+1)*(l+2)*(l+3)/6
i=0
while i<=l:
z-=f(a+i,b,c,l-i)+f(b+i,c,a,l-i)+f(c+i,a,b,l-i)
i+=1
print(z)
``` | instruction | 0 | 89,709 | 23 | 179,418 |
No | output | 1 | 89,709 | 23 | 179,419 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed not to increase the length of any stick.
Determine the number of ways to increase the lengths of some sticks so that you can form from them a non-degenerate (that is, having a positive area) triangle. Two ways are considered different, if the length of some stick is increased by different number of centimeters in them.
Input
The single line contains 4 integers a, b, c, l (1 β€ a, b, c β€ 3Β·105, 0 β€ l β€ 3Β·105).
Output
Print a single integer β the number of ways to increase the sizes of the sticks by the total of at most l centimeters, so that you can make a non-degenerate triangle from it.
Examples
Input
1 1 1 2
Output
4
Input
1 2 3 1
Output
2
Input
10 2 1 7
Output
0
Note
In the first sample test you can either not increase any stick or increase any two sticks by 1 centimeter.
In the second sample test you can increase either the first or the second stick by one centimeter. Note that the triangle made from the initial sticks is degenerate and thus, doesn't meet the conditions.
Submitted Solution:
```
a,b,c,l=map(int,input().split())
k=0
for i in range(l+1):
a1=a+i
for j in range(l-i+1):
b1=b+j
for k in range(l-i-j+1):
c1=c+k
if c1+b1>a1 and c1+a1>b1 and a1+b1>c1:
k+=1
print(k)
``` | instruction | 0 | 89,710 | 23 | 179,420 |
No | output | 1 | 89,710 | 23 | 179,421 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.