message stringlengths 2 59.7k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 37 108k | cluster float64 20 20 | __index_level_0__ int64 74 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES | instruction | 0 | 75,423 | 20 | 150,846 |
Tags: brute force, math
Correct Solution:
```
x = int(input())
b = 0
a=0
while b < 50 :
n = (b*(b+1)//2)
if ( n == x):
a = n
print ("YES")
break
b = b+1
if ( a == 0 ):
print ("NO")
``` | output | 1 | 75,423 | 20 | 150,847 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES | instruction | 0 | 75,424 | 20 | 150,848 |
Tags: brute force, math
Correct Solution:
```
n=int(input())
f=0
for i in range(1,n+1):
if (i*(i+1))//2==n:
f=1
break
if f==1:
print("YES")
else:
print("NO")
``` | output | 1 | 75,424 | 20 | 150,849 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES | instruction | 0 | 75,425 | 20 | 150,850 |
Tags: brute force, math
Correct Solution:
```
T=input("")
t=int(T)
a=0
i=0
while(a<t):
a=i*(i+1)/2
i=i+1
if(t==0):
print("NO")
elif(a==t):
print("YES")
else:
print("NO")
``` | output | 1 | 75,425 | 20 | 150,851 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES | instruction | 0 | 75,426 | 20 | 150,852 |
Tags: brute force, math
Correct Solution:
```
n = int(input())
possible = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]
if n in possible:
print("YES")
else:
print("NO")
``` | output | 1 | 75,426 | 20 | 150,853 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
x=int(input())
f=0
for i in range(1,x+1):
if (i*(i+1))//2==x:
f=1
break
if f:
print('YES')
else:
print('NO')
``` | instruction | 0 | 75,427 | 20 | 150,854 |
Yes | output | 1 | 75,427 | 20 | 150,855 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
n=int(input())
l=[]
s=0
for i in range(1,n+1):
s+=i
l.append(s)
if n in l :
print("YES")
else:
print("NO")
``` | instruction | 0 | 75,428 | 20 | 150,856 |
Yes | output | 1 | 75,428 | 20 | 150,857 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
from math import sqrt
t=int(input())
if (sqrt(1+8*t)-1)/2==(sqrt(1+8*t)-1)//2:
print("YES")
else:
print("NO")
``` | instruction | 0 | 75,429 | 20 | 150,858 |
Yes | output | 1 | 75,429 | 20 | 150,859 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
x = int(input())
t = ((-1+(1+8*x)**(1/2))/2)
r = int(t)
r1 = float(r)
if r1 == t:
print("YES")
else:
print("NO")
``` | instruction | 0 | 75,430 | 20 | 150,860 |
Yes | output | 1 | 75,430 | 20 | 150,861 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
n=int(input())
s=1
a=1
for i in range(n):
a+=1
s+=a
if s==n:
print("YES")
if s>n:
break
else:
print(-1)
``` | instruction | 0 | 75,431 | 20 | 150,862 |
No | output | 1 | 75,431 | 20 | 150,863 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
n=int(input())
if(n==1 or n%3==0):
print("YES")
else:
print("NO")
``` | instruction | 0 | 75,432 | 20 | 150,864 |
No | output | 1 | 75,432 | 20 | 150,865 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
def isTriangular(num):
if (num < 0):
return False
sum, n = 0, 1
while(sum <= num):
sum = sum + n
if (sum == num):
return True
n += 1
return False
n =int(input())
if (isTriangular(n)):
print("Yes")
else:
print("No")
``` | instruction | 0 | 75,433 | 20 | 150,866 |
No | output | 1 | 75,433 | 20 | 150,867 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. <image>. You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).
Your task is to find out if a given integer is a triangular number.
Input
The first line contains the single number n (1 β€ n β€ 500) β the given integer.
Output
If the given integer is a triangular number output YES, otherwise output NO.
Examples
Input
1
Output
YES
Input
2
Output
NO
Input
3
Output
YES
Submitted Solution:
```
n = int(input())
ans = "NO";
for i in range(n):
tri_num = i*(i+1)/2
if tri_num < n:
continue;
if tri_num == n:
ans = "YES"
break
print(ans)
``` | instruction | 0 | 75,434 | 20 | 150,868 |
No | output | 1 | 75,434 | 20 | 150,869 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,521 | 20 | 151,042 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
s=input()
a=s[0]
d,b=list(s[2:].split('e'))
if a=='0':
print(0 if d=='0' else '0.'+d)
else:
b=int(b)
len_d=len(d)
if b==0 and d=='0':
print(a)
else:
print(a+d[:b]+'.'+d[b:] if b<len_d else a+d+'0'*(b-len_d))
``` | output | 1 | 75,521 | 20 | 151,043 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,522 | 20 | 151,044 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
s = input()
a = s[0]
s = s[2:]
b = s[:s.find('e')]
d = int(s[s.find('e') + 1:])
s = ''
if d < 0:
s = '0.' + a
d -= 1
s += '0' * -d
d = 0
s += b
else:
s = a
while d > 0:
s += b[0]
b = b[1:] + '0'
d -= 1
s += '.' + b
while len(s) and s[0] == '0':
s = s[1:]
s = s[::-1]
while len(s) and s[0] == '0':
s = s[1:]
s = s[::-1]
if s[0] == '.':
s = '0' + s
if s[-1] == '.':
s = s[:-1]
print(s)
``` | output | 1 | 75,522 | 20 | 151,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,523 | 20 | 151,046 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
s = input()
a, b = s.split('e')
index = a.find('.')
ans = ''
if index == -1:
b = '0' * (int(b))
ans = a + b
else:
a1, a2 = a[:index], a[index + 1:]
if(int(a2) == 0):
ans = a1 + '0' * int(b)
elif len(a2) <= int(b):
ans = a1 + a2 + '0' * (int(b) - len(a2))
else:
a2 = a2[:int(b)] + '.' + a2[int(b):]
ans = a1 + a2
print(ans)
``` | output | 1 | 75,523 | 20 | 151,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,524 | 20 | 151,048 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
from decimal import *
n = Decimal(input())
if int(n) == n:
print(int(n))
else:
print(n)
``` | output | 1 | 75,524 | 20 | 151,049 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,525 | 20 | 151,050 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
s = input().split('.')
s[1] = s[1].split('e')
s = [s[0]] + s[1]
a = int(s[0])
d = int(s[1])
b = int(s[2])
if b >= len(s[1]):
ans = s[0] + s[1] + '0' * (b - len(s[1]))
print(ans)
else:
ans = s[0] + s[1][:b] + '.' + s[1][b:]
print(ans.rstrip('0').rstrip('.'))
``` | output | 1 | 75,525 | 20 | 151,051 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,526 | 20 | 151,052 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
s = str(input())
a = s[0]
d = s[2:s.find('e')]
b = int(s[s.find('e') + 1:]) + 1
a += d
while len(a) < b:
a += '0'
a = a[:b] + '.' + a[b:]
while a[0] == '0':
a = a[1:]
while a[-1] == '0':
a = a[:-1]
if a[0] == '.':
a = '0' + a
if a[-1] == '.':
a = a[:-1]
print(a)
``` | output | 1 | 75,526 | 20 | 151,053 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,527 | 20 | 151,054 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
integer, fraction, degree = input().replace('e', '.').split('.')
ans = integer
for i in range(len(fraction)):
if i == int(degree):
ans += '.'
ans += fraction[i]
for i in range(int(degree) - len(fraction)):
ans += '0'
if '.' in ans:
a, b = ans.split('.')
ans = str(int(a))
if int(b) != 0:
ans += '.' + b
print(ans)
``` | output | 1 | 75,527 | 20 | 151,055 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33 | instruction | 0 | 75,528 | 20 | 151,056 |
Tags: brute force, implementation, math, strings
Correct Solution:
```
s = input()
d, tmp = s.split(".")
r, exp = tmp.split("e")
if((int(d) == 0) & (int(r) == 0)) :
print("0")
else :
result = ""
rlen = len(r)
if(rlen <= int(exp)) :
tmp = int(exp)-rlen
zeros = ""
while(tmp > 0) :
zeros = zeros+"0"
tmp -= 1
result = d+r+zeros
else :
tmp1 = r[:int(exp)]
tmp2 = r[int(exp):]
if(int(tmp2) == 0) :
result = d + tmp1
else :
result = d + tmp1 + "." + tmp2
i = 0
count = 0
while((result[i] == '0') & ((i+1) < len(result))) :
if(result[i+1] != '.') :
count += 1
i += 1
print(result[count:])
``` | output | 1 | 75,528 | 20 | 151,057 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
s = input()
a = str()
b = str()
f = False
for i in range(len(s)):
if s[i] == 'e':
f = True
elif f:
b = b + s[i]
else:
a = a + s[i]
pos = a.index('.')
n = int(b)
a = list(a)
for i in range(n):
if pos == len(a) - 1:
a.append('0')
a[pos], a[pos + 1] = a[pos + 1], a[pos]
pos += 1
if a[-1] == '.':
a.pop()
if '.' in a:
while a[-1] == '0':
a.pop()
if a[-1] == '.':
a.pop()
if '.' not in a:
while len(a) > 1 and a[0] == '0':
a.pop(0)
for i in range(len(a)):
print(a[i], end = '')
``` | instruction | 0 | 75,529 | 20 | 151,058 |
Yes | output | 1 | 75,529 | 20 | 151,059 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
s = input().split('.')
a = int(s[0])
d, b = s[1].split('e')
b = int(b)
if b >= len(d):
print(str(a) + d + '0' * (b - len(d)))
else:
if len(d[b:]) == 1 and d[b] == '0':
print(str(a) + d[0:b])
else:
print(str(a) + d[0:b] + '.' + d[b:])
``` | instruction | 0 | 75,530 | 20 | 151,060 |
Yes | output | 1 | 75,530 | 20 | 151,061 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
a, b = input().split('e')
a = a[:1]+a[2:]
b = int(b)
a += '0' * 200
a = a[:b+1] + '.' + a[b+1:]
while a[-1] == '0':
a = a[:-1]
if a[-1] == '.':
a = a[:-1]
print(a)
``` | instruction | 0 | 75,531 | 20 | 151,062 |
Yes | output | 1 | 75,531 | 20 | 151,063 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
s = input()
b = s.split('.')
a = [b[0], b[1].split('e')[0], b[1].split('e')[1]]
a[2] = int(a[2])
s = a[0]
for i in range(a[2]):
if (i < len(a[1])):
s += a[1][i]
else:
s += '0'
if a[2] < len(a[1]):
s += '.'
for i in range(a[2], len(a[1])):
s += a[1][i]
joke = (False or len(s) == 1 or s[1] == '.')
j = ""
for i in range(len(s)):
if (not joke and s[i] == '0'):
pass
elif (not joke and s[i] != '0'):
joke = True
j += s[i]
else:
j += s[i]
k = len(j)
if k >= 2 and j[-1] == '0' and j[-2] == '.':
k -= 2
for i in range(k):
print(j[i], end = '')
``` | instruction | 0 | 75,532 | 20 | 151,064 |
Yes | output | 1 | 75,532 | 20 | 151,065 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
x = input().split("e")
prep = ""
stat = 0
cnt = 0
for i in x[0]:
if stat == 1 :
cnt += 1
if i != '.' :
prep += i
if i == '.':
stat = 1
add = int(x[1])
if cnt > add :
cnt -= add
get = len(prep) - cnt
for i in range(get):
print(prep[i], end="")
print(".",end="")
for i in range(get,len(prep)):
print(prep[i], end="")
print()
else:
add -= cnt
print(prep + "0"*add )
``` | instruction | 0 | 75,533 | 20 | 151,066 |
No | output | 1 | 75,533 | 20 | 151,067 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
n=input()
h=float(n)
print(h)
``` | instruction | 0 | 75,534 | 20 | 151,068 |
No | output | 1 | 75,534 | 20 | 151,069 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
from decimal import *
getcontext().prec = 100
n=input().split("e")
X=Decimal(n[0])
X*=pow(10,int(n[1]))
print(float(X))
``` | instruction | 0 | 75,535 | 20 | 151,070 |
No | output | 1 | 75,535 | 20 | 151,071 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
<image>
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A Γ 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 β€ a β€ 9, 0 β€ d < 10100, 0 β€ b β€ 100) β the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
Submitted Solution:
```
inp = input().split('.')
x = inp[1].split('e')
if len(x[0])>int(x[1]):
ans = (inp[0] + x[0][0:int(x[1])] + '.' + x[0][int(x[1]):])
elif(len(x[0]) == int(x[1])):
ans = (inp[0] + x[0])
else:
ans = (inp[0] + x[0] + '0'*(int(x[1]) - len(x[0])))
if float(ans) == int(float(ans)):
print(int(float(ans)))
else:
print(ans)
``` | instruction | 0 | 75,536 | 20 | 151,072 |
No | output | 1 | 75,536 | 20 | 151,073 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β₯ 0, 0 < r β€ 2k. Let's call that representation prairie partition of x.
For example, the prairie partitions of 12, 17, 7 and 1 are:
12 = 1 + 2 + 4 + 5,
17 = 1 + 2 + 4 + 8 + 2,
7 = 1 + 2 + 4,
1 = 1.
Alice took a sequence of positive integers (possibly with repeating elements), replaced every element with the sequence of summands in its prairie partition, arranged the resulting numbers in non-decreasing order and gave them to Borys. Now Borys wonders how many elements Alice's original sequence could contain. Find all possible options!
Input
The first line contains a single integer n (1 β€ n β€ 105) β the number of numbers given from Alice to Borys.
The second line contains n integers a1, a2, ..., an (1 β€ ai β€ 1012; a1 β€ a2 β€ ... β€ an) β the numbers given from Alice to Borys.
Output
Output, in increasing order, all possible values of m such that there exists a sequence of positive integers of length m such that if you replace every element with the summands in its prairie partition and arrange the resulting numbers in non-decreasing order, you will get the sequence given in the input.
If there are no such values of m, output a single integer -1.
Examples
Input
8
1 1 2 2 3 4 5 8
Output
2
Input
6
1 1 1 2 2 2
Output
2 3
Input
5
1 2 4 4 4
Output
-1
Note
In the first example, Alice could get the input sequence from [6, 20] as the original sequence.
In the second example, Alice's original sequence could be either [4, 5] or [3, 3, 3].
Submitted Solution:
```
from collections import Counter
from math import log2
powers = [2 ** p for p in range(64)]
def can():
near = Counter()
for num in set(nums):
p = int(log2(num))
near[p] += nums[num]
seq_cp = seqs - Counter()
for num in set(near):
cnt = near[num]
while cnt != 0 and num < 64:
dif = min(cnt, seq_cp[powers[num]])
cnt -= dif
seq_cp[powers[num]] -= dif
num += 1
if cnt > 0:
return False
return True
n = int(input())
seq = list(map(int, input().split()))
cnt = Counter(seq)
nums = Counter(seq)
seqs = Counter()
cur_cnt = cnt[1]
cur_pow = 1
while cur_cnt != 0:
nums[cur_pow] -= cur_cnt
cur_pow *= 2
if cur_cnt > cnt[cur_pow]:
seqs[cur_pow // 2] = cur_cnt - cnt[cur_pow]
cur_cnt = cnt[cur_pow]
for num in set(nums):
addition = nums[num]
nums[num] = 0
nums[2 ** int(log2(num))] += addition
# remove elements with zero count
nums -= Counter()
seqs -= Counter()
print(nums, seqs)
cur_len = sum(seqs[num] for num in set(seqs))
res = []
cur_pow = 1
while can():
res.append(cur_len)
while seqs[cur_pow] == 0 and cur_pow <= 2 ** 63:
cur_pow *= 2
if cur_pow > 2 ** 63:
break
other_pow = 1
while other_pow <= cur_pow:
nums[other_pow] += 1
other_pow *= 2
seqs[cur_pow] -= 1
cur_len -= 1
print(-1 if len(res) == 0 else ' '.join(map(str, reversed(res))))
``` | instruction | 0 | 75,555 | 20 | 151,110 |
No | output | 1 | 75,555 | 20 | 151,111 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β₯ 0, 0 < r β€ 2k. Let's call that representation prairie partition of x.
For example, the prairie partitions of 12, 17, 7 and 1 are:
12 = 1 + 2 + 4 + 5,
17 = 1 + 2 + 4 + 8 + 2,
7 = 1 + 2 + 4,
1 = 1.
Alice took a sequence of positive integers (possibly with repeating elements), replaced every element with the sequence of summands in its prairie partition, arranged the resulting numbers in non-decreasing order and gave them to Borys. Now Borys wonders how many elements Alice's original sequence could contain. Find all possible options!
Input
The first line contains a single integer n (1 β€ n β€ 105) β the number of numbers given from Alice to Borys.
The second line contains n integers a1, a2, ..., an (1 β€ ai β€ 1012; a1 β€ a2 β€ ... β€ an) β the numbers given from Alice to Borys.
Output
Output, in increasing order, all possible values of m such that there exists a sequence of positive integers of length m such that if you replace every element with the summands in its prairie partition and arrange the resulting numbers in non-decreasing order, you will get the sequence given in the input.
If there are no such values of m, output a single integer -1.
Examples
Input
8
1 1 2 2 3 4 5 8
Output
2
Input
6
1 1 1 2 2 2
Output
2 3
Input
5
1 2 4 4 4
Output
-1
Note
In the first example, Alice could get the input sequence from [6, 20] as the original sequence.
In the second example, Alice's original sequence could be either [4, 5] or [3, 3, 3].
Submitted Solution:
```
from collections import Counter
from math import log2, ceil
MAX = ceil(log2(10 ** 12))
def can():
seqs_cp = Counter(seqs)
for num in set(nums):
cnt = nums[num]
while cnt != 0 and num <= MAX:
dif = min(cnt, seqs_cp[num])
cnt -= dif
seqs_cp[num] -= dif
num *= 2
if cnt > 0:
return False
return True
n = int(input())
seq = list(map(int, input().split()))
cnt = Counter(seq)
nums = Counter(seq)
seqs = Counter()
cur_cnt = cnt[1]
cur_pow = 1
while cur_cnt != 0:
nums[cur_pow] -= cur_cnt
cur_pow *= 2
if cur_cnt > cnt[cur_pow]:
seqs[cur_pow // 2] = cur_cnt - cnt[cur_pow]
cur_cnt = cnt[cur_pow]
for num in set(nums):
addition = nums[num]
nums[num] = 0
nums[2 ** int(log2(num))] += addition
# remove elements with zero count
nums -= Counter()
seqs -= Counter()
cur_len = sum(seqs[num] for num in set(seqs))
res = []
cur_pow = 1
while can():
res.append(cur_len)
while seqs[cur_pow] == 0 and cur_pow <= MAX:
cur_pow *= 2
if cur_pow > MAX:
break
other_pow = 1
while other_pow <= cur_pow:
nums[other_pow] += 1
other_pow *= 2
seqs[cur_pow] -= 1
cur_len -= 1
print(-1 if len(res) == 0 else ' '.join(map(str, reversed(res))))
``` | instruction | 0 | 75,556 | 20 | 151,112 |
No | output | 1 | 75,556 | 20 | 151,113 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k β₯ 0, 0 < r β€ 2k. Let's call that representation prairie partition of x.
For example, the prairie partitions of 12, 17, 7 and 1 are:
12 = 1 + 2 + 4 + 5,
17 = 1 + 2 + 4 + 8 + 2,
7 = 1 + 2 + 4,
1 = 1.
Alice took a sequence of positive integers (possibly with repeating elements), replaced every element with the sequence of summands in its prairie partition, arranged the resulting numbers in non-decreasing order and gave them to Borys. Now Borys wonders how many elements Alice's original sequence could contain. Find all possible options!
Input
The first line contains a single integer n (1 β€ n β€ 105) β the number of numbers given from Alice to Borys.
The second line contains n integers a1, a2, ..., an (1 β€ ai β€ 1012; a1 β€ a2 β€ ... β€ an) β the numbers given from Alice to Borys.
Output
Output, in increasing order, all possible values of m such that there exists a sequence of positive integers of length m such that if you replace every element with the summands in its prairie partition and arrange the resulting numbers in non-decreasing order, you will get the sequence given in the input.
If there are no such values of m, output a single integer -1.
Examples
Input
8
1 1 2 2 3 4 5 8
Output
2
Input
6
1 1 1 2 2 2
Output
2 3
Input
5
1 2 4 4 4
Output
-1
Note
In the first example, Alice could get the input sequence from [6, 20] as the original sequence.
In the second example, Alice's original sequence could be either [4, 5] or [3, 3, 3].
Submitted Solution:
```
from collections import Counter
from math import log2, ceil
MAX = ceil(log2(10 ** 12))
def can():
seqs_cp = Counter(seqs)
for num in set(nums):
cnt = nums[num]
while cnt != 0 and num < MAX:
dif = min(cnt, seqs_cp[num])
cnt -= dif
seqs_cp[num] -= dif
num *= 2
if cnt > 0:
return False
return True
n = int(input())
seq = list(map(int, input().split()))
cnt = Counter(seq)
nums = Counter(seq)
seqs = Counter()
cur_cnt = cnt[1]
cur_pow = 1
while cur_cnt != 0:
nums[cur_pow] -= cur_cnt
cur_pow *= 2
if cur_cnt > cnt[cur_pow]:
seqs[cur_pow // 2] = cur_cnt - cnt[cur_pow]
cur_cnt = cnt[cur_pow]
for num in set(nums):
addition = nums[num]
nums[num] = 0
nums[2 ** int(log2(num))] += addition
# remove elements with zero count
nums -= Counter()
seqs -= Counter()
cur_len = sum(seqs[num] for num in set(seqs))
res = []
cur_pow = 1
while can():
res.append(cur_len)
while seqs[cur_pow] == 0 and cur_pow <= MAX:
cur_pow *= 2
if cur_pow > MAX:
break
other_pow = 1
while other_pow <= cur_pow:
nums[other_pow] += 1
other_pow *= 2
seqs[cur_pow] -= 1
cur_len -= 1
print(-1 if len(res) == 0 else ' '.join(map(str, reversed(res))))
``` | instruction | 0 | 75,557 | 20 | 151,114 |
No | output | 1 | 75,557 | 20 | 151,115 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,937 | 20 | 151,874 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n=int(input())
ans=[]
bad=[0]*n
curr=0
for i in range(n):
s=input()
num=[]
for j in s:
if j!='.':
num.append(j)
num=int(''.join(num))
if num%100000==0:
bad[i]=1
curr+=num%100000
ans.append(num//100000)
r=curr//100000
count=0
i=0
while count<r:
if bad[i]:
i+=1
continue
ans[i]+=1
i+=1
count+=1
print(' '.join(map(str,ans)))
``` | output | 1 | 75,937 | 20 | 151,875 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,938 | 20 | 151,876 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from math import floor
from sys import stdin
n = int(stdin.readline())
arr1,arr2,integers = [],[],[]
for i in range(n):
arr1.append(float(stdin.readline()))
arr2.append(floor(arr1[-1]))
integers.append(arr1[-1] == int(arr1[-1]))
s = -sum(arr2)
c = 0
for i in range(len(arr2)):
if s == c:
break
if not integers[i]:
arr2[i] += 1
c += 1
print(*arr2, sep='\n')
``` | output | 1 | 75,938 | 20 | 151,877 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,939 | 20 | 151,878 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
n = int(input())
k = []
chisla = []
summa = 0
for i in range (n):
x = float(input())
p = int(x)
if x < 0 and p != x:
k.append(-1)
elif x > 0 and p != x:
k.append(1)
else:
k.append(0)
chisla.append(p)
summa += p
#print(p)
#print(*k)
i = 0
#print(summa)
while summa != 0:
if summa > 0 and k[i] == -1:
summa -= 1
chisla[i] -= 1
if summa < 0 and k[i] == 1:
summa += 1
chisla[i] += 1
i += 1
for elem in chisla:
print(elem)
``` | output | 1 | 75,939 | 20 | 151,879 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,940 | 20 | 151,880 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import math
N = int(input())
arr = [0.0]*N
s = 0
for i in range(N):
n = float(input())
d = int(n)
if d<=n:
s += d
elif d>n:
s += d-1
#s += math.floor(n)
arr[i] = n
for i in range(N):
num = 0
d = int(arr[i])
#print(d)
if d==arr[i]:
C = d
F = d
elif d<arr[i]:
C = d+1
F = d
else:
C = d
F = d-1
if s<0 and not arr[i].is_integer():
s += 1
num = C
else:
num = F
print(num)
``` | output | 1 | 75,940 | 20 | 151,881 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,941 | 20 | 151,882 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from math import floor, ceil
import sys
def main():
n = int(sys.stdin.readline())
isum = 0
isumcopy = 0
for i in range(n):
num = float(sys.stdin.readline())
if int(num) == num:
print(int(num))
continue
isum += num
f = ceil(num)
s = floor(num)
if abs(isumcopy + f - isum) <= abs(isumcopy + s - isum):
sys.stdout.write(str(f)+'\n')
isumcopy += f
else:
sys.stdout.write(str(s)+'\n')
isumcopy += s
main()
``` | output | 1 | 75,941 | 20 | 151,883 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,942 | 20 | 151,884 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
g = 0
h = []
a = int(input())
for i in range(a):
s = float(input())
g += int(s)
if float(int(s)) == s:
k = False
else:
k = True
h.append([int(s), k, s > 0])
for i in range(len(h)):
if g == 0:
break
if not h[i][1]:
continue
if g < 0:
if h[i][0] > 0 or (h[i][0] >= 0 and h[i][2]):
h[i][0] += 1
g += 1
else:
if h[i][0] < 0:
h[i][0] -= 1
g -= 1
for i in h:
print(i[0])
``` | output | 1 | 75,942 | 20 | 151,885 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,943 | 20 | 151,886 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from math import floor,ceil
n=int(input())
arr=[]
arr2=[]
for x in range(n):
arr.append(float(input()))
for x in arr:
arr2.append(floor(x))
total=sum(arr2)
if total<0:
x=0
y=0
while(y<abs(total)):
if floor(arr[x])!=arr[x]:
arr2[x]+=1
y+=1
x+=1
else:
x=0
y=0
while(y<abs(total)):
if floor(arr[x])!=arr[x]:
arr2[x]-=1
y+=1
x+=1
for x in arr2:
print(x)
``` | output | 1 | 75,943 | 20 | 151,887 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down. | instruction | 0 | 75,944 | 20 | 151,888 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
numbers = []
d = []
# -1 - ΠΎΡΡ 0 - ΠΏΠΎΠ»ΠΎΠΆ 1 - ΠΏΠΎΠ»ΠΎΠΆ
s = 0
for i in range(int(input())):
n = input()
if n[len(n) - 5:] == "00000":
num = int(n[:len(n) - 6])
numbers.append(num)
s += num
d.append(0)
elif n[0] == '-':
num = int(n[:len(n) - 6]) - 1
numbers.append(num)
s += num
d.append(-1)
else:
num = int(n[:len(n) - 6])
numbers.append(num)
s += num
d.append(1)
if s == 0:
for i in numbers:
print(i)
else:
for i in range(len(numbers)):
if s < 0:
if d[i] != 0:
s += 1
print(numbers[i] + 1)
else:
print(numbers[i])
else:
print(numbers[i])
``` | output | 1 | 75,944 | 20 | 151,889 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
import sys
input=sys.stdin.readline
import math
n=int(input())
integer=[0]*(n+1)
exact,up,down,summa=[],[],[],0
for i in range(n):
a=float(input())
if a==int(a):
integer[i]=1
up.append(math.ceil(a))
j,i=0,0
posi=sum(up)
while posi>i:
if integer[j]!=1:
up[j]-=1
i+=1
j+=1
#print(j,sum(up),i)
for j in up:
sys.stdout.write(str(j)+'\n')
``` | instruction | 0 | 75,945 | 20 | 151,890 |
Yes | output | 1 | 75,945 | 20 | 151,891 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
import math
n=int(input())
w=[]
A=0;
D=0;
for i in range(0,n):
f=float(input())
w.append(f)
if f<0:
A+=math.ceil(f)
else:
D+=math.floor(f);
A=abs(A)
D=abs(D)
T=abs(A-D)
if A==D and T==0:
for i in range(0,len(w)):
if w[i] < 0:
print(math.ceil(w[i]),end=' ')
else:
print(math.floor(w[i]),end=' ')
elif(A>D):
for i in range(0,len(w)):
# print(int(w[i]),int(math.floor(w[i])))
if T!=0:
if w[i]>=0 and int(w[i])!=(w[i]):
print(math.ceil(w[i]),end=' ')
T-=1;
else:
if w[i] < 0:
print(math.ceil(w[i]),end=' ')
else:
print(math.ceil(w[i]),end=' ')
else:
if w[i] < 0:
print(math.ceil(w[i]),end=' ')
else:
print(math.floor(w[i]),end=' ')
else:
for i in range(0,len(w)):
if T!=0:
if w[i]<0 and int(w[i])!=(w[i]):
print(math.floor(w[i]),end=' ')
T-=1;
else:
if w[i] < 0:
print(math.floor(w[i]),end=' ')
else:
print(math.floor(w[i]),end=' ')
else:
if w[i] < 0:
print(math.ceil(w[i]),end=' ')
else:
print(math.floor(w[i]),end=' ')
``` | instruction | 0 | 75,946 | 20 | 151,892 |
Yes | output | 1 | 75,946 | 20 | 151,893 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
n = int(input())
original = []
control = []
for i in range(n):
a = float(input())
original.append(a)
control.append(int(a))
sum_all = sum(control)
if sum_all > 0:
while sum_all > 0:
for i in range(len(control)):
if control[i] > original[i] :
control[i] -= 1
sum_all -= 1
if sum_all == 0:
break
elif sum_all < 0:
while sum_all < 0:
for i in range(len(control)):
if control[i] < original[i] :
control[i] += 1
sum_all += 1
if sum_all == 0:
break
for i in range(len(control)):
print(control[i])
``` | instruction | 0 | 75,947 | 20 | 151,894 |
Yes | output | 1 | 75,947 | 20 | 151,895 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
import math
n = int(input())
L=[]
ceil=0
LL=[]
for i in range(n):
f = float(input())
L.append(f)
LL.append(math.ceil(f))
ceil+=math.ceil(f)
#print(L,LL,ceil)
count=0
for i in range(n):
if abs(L[i]-LL[i])>0:
LL[i]=math.floor(L[i])
count+=1
if count==ceil:
break
for i in range(n):
print(LL[i],end=' ')
#I round down ceil numbers
``` | instruction | 0 | 75,948 | 20 | 151,896 |
Yes | output | 1 | 75,948 | 20 | 151,897 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
import sys
import math
from collections import Counter
from operator import itemgetter
import queue
def IO():
sys.stdin=open("pyinput.txt", 'r')
sys.stdout=open("pyoutput.txt", 'w')
def GCD(a, b):
if(b==0): return a
else: return GCD(b, a%b)
def LCM(a, b): return a*(b//GCD(a, b))
def scan(TYPE_1, TYPE_2=0):
if(TYPE_1==int):
return map(int, sys.stdin.readline().strip().split())
elif(TYPE_1==float):
return map(float, sys.stdin.readline().strip().split())
elif(TYPE_1==list and TYPE_2==float):
return list(map(float, sys.stdin.readline().strip().split()))
elif(TYPE_1==list and TYPE_2==int):
return list(map(int, sys.stdin.readline().strip().split()))
elif(TYPE_1==str):
return sys.stdin.readline().strip()
else: print("ERROR!!!!")
def main():
n=int(input())
a=[]
x=[]
s=0
for i in range(n):
x.append(float(scan(str)))
a.append(int(x[i]))
s+=a[i]
for i in range(n):
if(s<0 and a[i]>=0 and x[i]>0):
a[i]+=1
s+=1
if(s>0 and a[i]<=0 and x[i]<0):
a[i]-=1
s-=1
print(*a, sep='\n')
# IO()
main()
``` | instruction | 0 | 75,949 | 20 | 151,898 |
No | output | 1 | 75,949 | 20 | 151,899 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
inputs = int(input())
numbers = []
for i in range(inputs):
x = float(input())
numbers.append(round(x))
for j in range(inputs):
print(numbers[j])
``` | instruction | 0 | 75,950 | 20 | 151,900 |
No | output | 1 | 75,950 | 20 | 151,901 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
"""
Code of Ayush Tiwari
Codeforces: servermonk
Codechef: ayush572000
"""
#import sys
#input = sys.stdin.buffer.readline
#Fast IO
import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
from future_builtins import ascii, filter, hex, map, oct, zip
range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
newlines = 0
def __init__(self, file):
self._file = file
self._fd = file.fileno()
self.writable = "x" in file.mode or "w" in file.mode
self.write = super(FastIO, self).write if self.writable else None
def _fill(self):
s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
return s
def read(self):
while self._fill(): pass
return super(FastIO,self).read()
def readline(self):
while self.newlines == 0:
s = self._fill(); self.newlines = s.count(b"\n") + (not s)
self.newlines -= 1
return super(FastIO, self).readline()
def flush(self):
if self.writable:
os.write(self._fd, self.getvalue())
self.truncate(0), self.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
if py2:
self.write = self.buffer.write
self.read = self.buffer.read
self.readline = self.buffer.readline
else:
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')
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
# Cout implemented in Python
import sys
class ostream:
def __lshift__(self,a):
sys.stdout.write(str(a))
return self
cout = ostream()
endl = '\n'
def solution():
# This is the main code
n=int(input())
s=0
ans=[0]*n
l=[]
for i in range(n):
f=float(input())
s+=int(f)
ans[i]=int(f)
l.append(f)
for i in range(n):
if s==0:
break
if l[i]-int(l[i])==0:
continue
ans[i]+=1
s-=1
for i in range(n):
print(ans[i])
t=1
for _ in range(t):
solution()
``` | instruction | 0 | 75,951 | 20 | 151,902 |
No | output | 1 | 75,951 | 20 | 151,903 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vus the Cossack has n real numbers a_i. It is known that the sum of all numbers is equal to 0. He wants to choose a sequence b the size of which is n such that the sum of all numbers is 0 and each b_i is either β a_i β or β a_i β. In other words, b_i equals a_i rounded up or down. It is not necessary to round to the nearest integer.
For example, if a = [4.58413, 1.22491, -2.10517, -3.70387], then b can be equal, for example, to [4, 2, -2, -4].
Note that if a_i is an integer, then there is no difference between β a_i β and β a_i β, b_i will always be equal to a_i.
Help Vus the Cossack find such sequence!
Input
The first line contains one integer n (1 β€ n β€ 10^5) β the number of numbers.
Each of the next n lines contains one real number a_i (|a_i| < 10^5). It is guaranteed that each a_i has exactly 5 digits after the decimal point. It is guaranteed that the sum of all the numbers is equal to 0.
Output
In each of the next n lines, print one integer b_i. For each i, |a_i-b_i|<1 must be met.
If there are multiple answers, print any.
Examples
Input
4
4.58413
1.22491
-2.10517
-3.70387
Output
4
2
-2
-4
Input
5
-6.32509
3.30066
-0.93878
2.00000
1.96321
Output
-6
3
-1
2
2
Note
The first example is explained in the legend.
In the second example, we can round the first and fifth numbers up, and the second and third numbers down. We can round the fourth number neither up, nor down.
Submitted Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = 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(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")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#-------------------game starts now-----------------------------------------------------
n=int(input())
pos=list()
neg=list()
s1=0
s2=0
for i in range (n):
n=float(input())
n=int(n)
if n>=0:
pos.append([i,n])
s1+=n
else:
neg.append([i,n])
s2+=abs(n)
if s1>s2:
c=s1-s2
for i in range (c):
neg[i][1]-=1
elif s2>s1:
c=s2-s1
for i in range (c):
pos[i][1]+=1
res=pos+neg
res.sort()
for i in res:
print(i[1])
``` | instruction | 0 | 75,952 | 20 | 151,904 |
No | output | 1 | 75,952 | 20 | 151,905 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.
For example, the following numbers are round: 4000, 1, 9, 800, 90. The following numbers are not round: 110, 707, 222, 1001.
You are given a positive integer n (1 β€ n β€ 10^4). Represent the number n as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number n as a sum of the least number of terms, each of which is a round number.
Input
The first line contains an integer t (1 β€ t β€ 10^4) β the number of test cases in the input. Then t test cases follow.
Each test case is a line containing an integer n (1 β€ n β€ 10^4).
Output
Print t answers to the test cases. Each answer must begin with an integer k β the minimum number of summands. Next, k terms must follow, each of which is a round number, and their sum is n. The terms can be printed in any order. If there are several answers, print any of them.
Example
Input
5
5009
7
9876
10000
10
Output
2
5000 9
1
7
4
800 70 6 9000
1
10000
1
10 | instruction | 0 | 76,022 | 20 | 152,044 |
Tags: implementation, math
Correct Solution:
```
def Number_As_A_Sum(N):
L = []
Power = 1
while N > 0:
use = N//10
update = use*10
K = N - update
KP = K*Power
if KP != 0:
L.append(KP)
Power = Power*10
N = N//10
return L
T = int(input())
for i in range(T):
N = int(input())
Set = Number_As_A_Sum(N)
Length = len(Set)
print(Length)
for i in range(Length):
print(Set[i],end=" ")
print()
``` | output | 1 | 76,022 | 20 | 152,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.
For example, the following numbers are round: 4000, 1, 9, 800, 90. The following numbers are not round: 110, 707, 222, 1001.
You are given a positive integer n (1 β€ n β€ 10^4). Represent the number n as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number n as a sum of the least number of terms, each of which is a round number.
Input
The first line contains an integer t (1 β€ t β€ 10^4) β the number of test cases in the input. Then t test cases follow.
Each test case is a line containing an integer n (1 β€ n β€ 10^4).
Output
Print t answers to the test cases. Each answer must begin with an integer k β the minimum number of summands. Next, k terms must follow, each of which is a round number, and their sum is n. The terms can be printed in any order. If there are several answers, print any of them.
Example
Input
5
5009
7
9876
10000
10
Output
2
5000 9
1
7
4
800 70 6 9000
1
10000
1
10 | instruction | 0 | 76,023 | 20 | 152,046 |
Tags: implementation, math
Correct Solution:
```
t=int(input())
for i in range(t):
x=int(input())
string=str(x)
l=len(string)
c=l
li=[]
for i in range(1,l+1):
ans=int(string[i-1])*pow(10,c-i)
if(int(ans)!=0):
li.append(ans)
co=len(li)
print(co)
for i in li:
print(i,end=" ")
print()
``` | output | 1 | 76,023 | 20 | 152,047 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from 1 to 9 (inclusive) are round.
For example, the following numbers are round: 4000, 1, 9, 800, 90. The following numbers are not round: 110, 707, 222, 1001.
You are given a positive integer n (1 β€ n β€ 10^4). Represent the number n as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number n as a sum of the least number of terms, each of which is a round number.
Input
The first line contains an integer t (1 β€ t β€ 10^4) β the number of test cases in the input. Then t test cases follow.
Each test case is a line containing an integer n (1 β€ n β€ 10^4).
Output
Print t answers to the test cases. Each answer must begin with an integer k β the minimum number of summands. Next, k terms must follow, each of which is a round number, and their sum is n. The terms can be printed in any order. If there are several answers, print any of them.
Example
Input
5
5009
7
9876
10000
10
Output
2
5000 9
1
7
4
800 70 6 9000
1
10000
1
10 | instruction | 0 | 76,024 | 20 | 152,048 |
Tags: implementation, math
Correct Solution:
```
testCount = int(input())
for _ in range(testCount):
n = int(input())
addendums = []
currentBase = 1
while currentBase <= n:
currentBase *= 10
addendum = n % currentBase
if addendum > 0:
n -= addendum
addendums.append(addendum)
print(len(addendums))
print(*addendums)
``` | output | 1 | 76,024 | 20 | 152,049 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.