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. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2
instruction
0
27,020
20
54,040
Tags: implementation, strings Correct Solution: ``` s = input() if not ('.' in s): s = s + '.' a, b = s.strip('0').split('.') if not a: newb = b.strip('0') poc, l, r = len(newb) - len(b) - 1, newb[0], newb[1:] else: poc, l, r = len(a) - 1, a[0], (a[1:] + b).rstrip('0') if l: print(l, end = '') else: print(0, end = '') if r: print('.' + r, end = '') if poc: print('E%d' % poc, end = '') ```
output
1
27,020
20
54,041
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2
instruction
0
27,021
20
54,042
Tags: implementation, strings Correct Solution: ``` def out(M, p): if p==0: return M else: out='{0}E{1}'.format(M, p) return out res=0 a=0 inp=list(str(input())) for it in '123456789': if (it in inp)==True: res+=1 if res==0: res=-1 print('0') else: res=0 while res==0: res-=1 i=0 k=0 while inp[k]=='0': k+=1 inp=inp[k:] if inp[0]=='.': inp.insert(0, '0') if inp[len(inp)-1]=='.': inp.remove(inp[len(inp)-1]) if ('.' in inp)==True: while True: if inp[i]!='.': i+=1 else: break inp.reverse() k=0 while inp[k]=='0': k+=1 inp=inp[k:] if inp[0]=='.': inp.remove('.') inp.reverse() res-=1 if ('.' in inp)==False: i=len(inp) inp.insert(1, '.') inp.reverse() k=0 while inp[k]=='0': k+=1 inp=inp[k:] while inp[0]=='.': inp.remove('.') inp.reverse() inp=''.join(inp) a-=1 print(out(inp, i-1)) if ('.' in inp)==True and len(inp[:i])==1: i=0 if inp[0]=='0': inp.remove('.') k=0 while inp[i]=='0': i+=1 inp=inp[i:] inp.insert(1, '.') if inp[len(inp)-1]=='.': inp.remove('.') a=-1 print(out(''.join(inp), -i)) if ('.' in inp)==True and len(inp[:i])>1 and a==0: inp.remove('.') inp.insert(1, '.') inp=''.join(inp) print(out(inp, i-1)) else: i=len(inp) inp.insert(1, '.') inp.reverse() k=0 while inp[k]=='0': k+=1 inp=inp[k:] while inp[0]=='.': inp.remove('.') inp.reverse() inp=''.join(inp) print(out(inp, i-1)) ```
output
1
27,021
20
54,043
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2
instruction
0
27,022
20
54,044
Tags: implementation, strings Correct Solution: ``` def count_leading_zeroes(inp, leading=True): tot = 0 search_str = inp if leading else inp[::-1] for char in search_str: if char == '0': tot+=1 else: return tot return tot raw = input() left, dot, right = raw.partition('.') left = left.lstrip('0') right = right.rstrip('0') l,r = len(left), len(right) if l==0 and r==0: print(0) else: if l==0: B = count_leading_zeroes(right) A1 = right[B] A2 = right[B+1:] B = -B-1 elif r==0: A1 = left[0] A2 = left[1:] B = len(A2) else: A1 = left[0] A2 = left[1:] + right B = len(left[1:]) A2 = A2.rstrip('0') final_str = A1 if not (A2 == '' or A2 == 0): final_str+='.'+A2 if not (B=='' or B==0): final_str+='E{B}'.format(B=B) print(final_str) ```
output
1
27,022
20
54,045
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2
instruction
0
27,023
20
54,046
Tags: implementation, strings Correct Solution: ``` import re s = input() if '.' not in s: s += '.' a,b = s.split('.') p = 0 while p < len(a) and a[p] == '0': p+=1 a = a[p:] if a == '': a = '0' tmp = a[1:] e = len(tmp) b = a[1:] + b p = len(b) - 1 while p >= 0 and b[p] == '0': p-=1 b = b[:p+1] a = a[0] if a == '0' and b != '': p = 0 while b[p] == '0': p+=1 a = b[p] b = b[p+1:] e = -p -1 ans = a + ('.' if b != '' else '') + b + ('E' + str(e) if e != 0 else '') print(ans) ```
output
1
27,023
20
54,047
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2
instruction
0
27,024
20
54,048
Tags: implementation, strings Correct Solution: ``` x = input() if "." in x: c, d = x.split(".") else: c, d = x, "" c = c.lstrip("0") d = d.rstrip("0") if c: b = len(c) - 1 a = c + d a1 = a[0] a2 = a[1:].rstrip("0") a = (a1 + "." + a2).rstrip("0").rstrip(".") if b == 0: print(a, sep="", end="") else: print(a, "E", b, sep="", end="") else: b = -1 for i in d: if i == "0": b -= 1 else: break a = d.lstrip("0") a1 = a[0] a2 = a[1:].rstrip("0") a = (a1 + "." + a2).rstrip("0").rstrip(".") print(a, "E", b, sep="", end="") ```
output
1
27,024
20
54,049
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` x=input() def dn(x): n=0 for i in x[::-1]: if i=="0": n-=1 elif i==".": n-=1 pass else: if n==0: return x else: return x[:n] if "." not in x: x+="." for n,i in enumerate(x): if i!="0": x=x[n:] break d=x.find(".")-1 if d<0: for n, i in enumerate(x[1:]): if i!="0": d-=n break if x==".": print(0) else: if d==0: if len(x)==2: print(x[0]) else: print(dn(x)) elif d>0: exp="E"+str(d) print(dn(x[0]+"."+x[1:d+1]+x[d+2:])+exp) else: exp="E"+str(d) x=x[-d:] x=x[0]+"."+x[1:] print(dn(x)+exp) ```
instruction
0
27,025
20
54,050
Yes
output
1
27,025
20
54,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` import sys s = input() if '.' not in s: s += ".0" if s[0]=='.': s='0'+s if s[-1]=='.': s=s+'0' i=0 while s[i]=='0':i+=1 if s[i]=='.':i-=1 s=s[i:] i=len(s)-1 while s[i]=='0':i-=1 if s[i]=='.':i+=1 s=s[:i+1] i=s.index('.') if i==1 and s[0]=='0': e=1 i=2 while s[i]=='0': i+=1 e+=1 res=s[i]+'.'+s[i+1:] if res[-1]=='.':res=res[:-1] res+='E'+str(-e) print(res) sys.exit(0) if i==1: i=len(s)-1 while s[i] == '0': i -= 1 s = s[:i + 1] if s[-1] == '.': s = s[:-1] print(s) sys.exit(0) e=i-1 s=s.replace('.','') s=s[0]+'.'+s[1:] i=len(s)-1 while s[i]=='0':i-=1 s=s[:i+1] if s[-1]=='.':s=s[:-1] res=s+'E'+str(e) print(res) ```
instruction
0
27,026
20
54,052
Yes
output
1
27,026
20
54,053
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` s = input() if not '.' in s: s = s + '.' i = 0; zer = 0; step = 0 while s[i] == '0': zer += 1 i += 1 s = s[zer:] zer = 0 #print(s) i = len(s) - 1 while s[i] == '0': zer += 1 i -= 1 if zer > 0: s = s[:-zer] '''if not '.' in s: step = zer s = s + '.''' #print(s, step) i = s.index('.') if len(s[i:]) > 1 and i == 0: i += 1 step -= 1 while s[i] == '0': i += 1 step -= 1 elif i == len(s) - 1: i -= 1 while s[i] == '0': i -= 1 step += 1 i = s.index('.') #print(s, step, i) if len(s) == 2 and step == 0: print(s[0]) #print('case 1') elif len(s[:-step - 1]) == 1 and step > 0: print(s[0] + 'E' + str(step)) #print('case 2') elif len(s[:i]) == 1 and step == 0: print(s[0] + '.' + s[i + 1:]) #print('case 3') elif step == 0: print(s[0] + '.' + s[1:i] + s[i+1:] + 'E' + str(len(s[1:i]))) #print('case 4') elif step > 0: print(s[0] + '.' + s[1:i - step] + s[i+1:] + 'E' + str(len(s[1:i - step]) + step)) #print('case 5') elif step < 0 and len(s[-step:]) == 1: print(s[-step] + s[-step + 1:] + 'E' + str(step)) #print('case 6') elif step < 0: print(s[-step] + '.' + s[-step + 1:] + 'E' + str(step)) #print('case 7') ```
instruction
0
27,027
20
54,054
Yes
output
1
27,027
20
54,055
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` def task(n): l,r = n.partition('.')[::2] l = l.lstrip('0') exp = None if l: exp = len(l) - 1 r = l[1:]+r l = l[0] else: strippedr = r.lstrip('0') exp = len(strippedr) - len(r) - 1 l = strippedr[0] r = strippedr[1:] r = r.rstrip('0') return l + (('.%s' % r) if r else '') + (('E%d' % exp) if exp else '') n = [input()] #n = ['16', '01.23400', '.100', '100.'] for t in n: print(task(t)) ```
instruction
0
27,028
20
54,056
Yes
output
1
27,028
20
54,057
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` from math import * s = float(input()) f = '{:e}'.format(s) a, b = f.split('e') b = b[0]+b[1:].strip('0') ans = a.strip('0').strip('.') + 'E' + b.strip('+').strip('0') print(ans.strip('E')) ```
instruction
0
27,029
20
54,058
No
output
1
27,029
20
54,059
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` a = input() if '.' not in a: a+='.' while a[0]=='0': a=a[1::] while a[-1]=='0': a=a[0:-1] #cлучай отрицательной экспоненты if a[0]==".": b=0 while a[1]=='0': b-=1 a='.'+a[2::] b-=1 a=a[1]+'.'+a[2::] print(a+"E"+str(b)) #случай положительной экспоненты else: print(a) b=a.index('.')-1 a=a.replace('.','') print(a[0]+'.'+a[1::]+"E"+str(b)) ```
instruction
0
27,030
20
54,060
No
output
1
27,030
20
54,061
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` x = input() if "." in x: x = x.strip("0") else: x = x.lstrip("0") l = len(x) ''' id = x.find(".") print(id) ''' ''' x += '8888' print(x) ''' if "." not in x: b = l - 1 x = x.rstrip("0") x = x[0:1] + "." + x[1:] x = x.rstrip(".") x += "E" x += str(b) elif x[0] == '.': if l == 2: x = x.lstrip(".") x += "E" x += "-1" else: x = x.lstrip(".") x = x.lstrip("0") b = l - len(x) x = x[0:1] + "." + x[1:] x += "E-" x += str(b) elif x[l-1] == ".": b = l - 2 x = x.rstrip(".") x = x[0:1] + "." +x[1:] x = x.rstrip("0") x = x.rstrip(".") x += "E" x += str(b) elif x[1] == ".": pass else: id = x.find(".") b = id - 1 x = x[0:1] + "." + x[1:id] + x[id+1:] x += "E" x += str(b) print(x) ```
instruction
0
27,031
20
54,062
No
output
1
27,031
20
54,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a positive decimal number x. Your task is to convert it to the "simple exponential notation". Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in a and b. Input The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other. Output Print the only line — the "simple exponential notation" of the given number x. Examples Input 16 Output 1.6E1 Input 01.23400 Output 1.234 Input .100 Output 1E-1 Input 100. Output 1E2 Submitted Solution: ``` # @Date : 2016-08-24 17:06:48 # @Problem : import unittest from random import randint, shuffle from sys import maxsize class StressTest(unittest.TestCase): known_values = ( # A[:], expected ("16", "1.6E1"), ("01.23400", "1.234"), (".100", "1E-1"), ("100.", "1E2") ) def test_known_cases(self): for a, expected in self.known_values: self.assertEqual(expected, solution(a)) def test_all_cases(self): while True: break def cleanZeros(a): p = 0 q = len(a)-1 while p < len(a) and a[p] == '0': p += 1 while q >= 0 and a[q] == '0': q -= 1 return a[p:q+1] def solution(a): if '.' not in a: a = a + '.' a = cleanZeros(a) #if '.' not in a: # a = a + '.' dotIndex = a.index('.') exp = str(dotIndex-1) a = ''.join(a.split('.')) afterDot = cleanZeros(a[1:]) dot = '.' if afterDot else '' end = 'E' + exp if exp != '0' else '' return a[0] + dot + afterDot + end if __name__ == '__main__': #unittest.main() print(solution(input())) ```
instruction
0
27,032
20
54,064
No
output
1
27,032
20
54,065
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,033
20
54,066
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) current = 2 for i in range(n): next = (i+1) * (i+2) press = (i+1) * (i+2) * (i+2) - current // (i+1) current = next print(press) ```
output
1
27,033
20
54,067
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,034
20
54,068
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) for i in range(1,n+1) : if i == 1 : print(2) else : print((i+1)*(i+1)*i-(i-1)) ```
output
1
27,034
20
54,069
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,035
20
54,070
Tags: constructive algorithms, math Correct Solution: ``` def solve(): n = int(input()) k = 1 m = 2 while k <= n: a = m // k b = (k+1)**2*k - a print(b) m = k * (k+1) k += 1 if __name__ == '__main__': solve() ```
output
1
27,035
20
54,071
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,036
20
54,072
Tags: constructive algorithms, math Correct Solution: ``` __author__ = 'Think' data=input().split()[0] n=int(data) screen=2 for level in range(1, n+1): if screen/level != screen//level: print("Broken", screen, level) print(level*(level+1)**2-screen//level) screen=level*(level+1) ```
output
1
27,036
20
54,073
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,037
20
54,074
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) last = 2 print(2) for i in range(2, n + 1): #print(last) new = (i * (i + 1)) ** 2 #$print(new, last) q = (new - last) // i print(q) #print((new - last) // i) last = i * (i + 1) ```
output
1
27,037
20
54,075
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,038
20
54,076
Tags: constructive algorithms, math Correct Solution: ``` import math n = int(input()) x = 2 k = 1 while k != n + 1: v = math.floor(math.sqrt(x)) while 1 == 1: u = v * v - x if u % k == 0: t = int(v * v * (k + 2) + u / k) x = int(math.sqrt(x + t * k)) print(t) k = k + 1 break v = v + 1 ```
output
1
27,038
20
54,077
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,039
20
54,078
Tags: constructive algorithms, math Correct Solution: ``` n=int(input()) cur=2 for level in range (1,n+1): next=level*(level+1) print(int((next*next-cur)/level)) cur=next ```
output
1
27,039
20
54,079
Provide tags and a correct Python 3 solution for this coding contest problem. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3.
instruction
0
27,040
20
54,080
Tags: constructive algorithms, math Correct Solution: ``` n = int(input()) last = 2 for i in range(1, n + 1): curr = (i * (i + 1)) ** 2 print((curr - last) // i) last = i * (i + 1) ```
output
1
27,040
20
54,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n = int(input()) print(2) for i in range(2, n + 1): print(((i * (i + 1)) ** 2 - i * (i - 1)) // i) ```
instruction
0
27,041
20
54,082
Yes
output
1
27,041
20
54,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n=int(input()) c=2 for i in range(n): print((i+2)*(i+2)*(i+1)-c//(i+1)) c=(i+2)*(i+1) ```
instruction
0
27,042
20
54,084
Yes
output
1
27,042
20
54,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` from math import sqrt def pow1(x, base): sq = 1 while (base > 0): if base % 2: base -= 1 sq = (sq * x) # % mod base //= 2 x = (x * x) # % mod return sq n, cum, root, tem = int(input()), [4], [2], 2 for i in range(1, n + 1): print(int((cum[-1] - tem) // i)) cum.append(pow1(root[-1] + (2 * (i + 1)), 2)) root.append(root[-1] + (2 * (i + 1))) tem = int(root[-2]) ```
instruction
0
27,043
20
54,086
Yes
output
1
27,043
20
54,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` import math def solve_eq(a, lvl): lvl2 = (lvl+1)**2 q = max(int(math.sqrt(a % lvl2)), 1) while(q*q*lvl2 < a): q += 1 while((q*q*lvl2 - a) % lvl != 0): q += 1 return (lvl+1)*q, int((q*q*lvl2 - a)/lvl) def find_nums(n): a = 2 for i in range(1, n+1): a, tmp = solve_eq(a, i) print(tmp) find_nums(int(input())) ```
instruction
0
27,044
20
54,088
Yes
output
1
27,044
20
54,089
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` # Hello World program in Python n = int(input()) t = 2; for i in range(1, n + 1): ans = i * i * (i + 1) * (i + 1) - t; t = i * (i + 1) print(ans) ```
instruction
0
27,045
20
54,090
No
output
1
27,045
20
54,091
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` n=int(input()) c=1 s=4 for i in range(1,n+1): s=i**2*(i+1)**2 t=int((s-c)/i) print(t) c=int(s**0.5) ```
instruction
0
27,046
20
54,092
No
output
1
27,046
20
54,093
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` from sys import stdin, stdout, stderr import math n = int(stdin.readline()) def go(lvl: int, cur: int, l: list): if (cur % lvl != 0): return False if(lvl == n + 1): return True for dx in range(0, 100000): cur += dx * lvl if(cur % lvl != 0): cur -= dx * lvl return False x = int(math.sqrt(cur)) if(x * x == cur): l.append(dx) if(go(lvl + 1, x, l)): return True l.pop() cur -= dx * lvl def main(): cur = 2 for lvl in range(1, n+2): stdout.write("2\n" if (lvl == 1) else str(lvl*(lvl+1)*(lvl+1) - lvl+1) + '\n') if __name__ == '__main__': main() ```
instruction
0
27,047
20
54,094
No
output
1
27,047
20
54,095
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder start at the level 1. When ZS the Coder is at level k, he can : 1. Press the ' + ' button. This increases the number on the screen by exactly k. So, if the number on the screen was x, it becomes x + k. 2. Press the '<image>' button. Let the number on the screen be x. After pressing this button, the number becomes <image>. After that, ZS the Coder levels up, so his current level becomes k + 1. This button can only be pressed when x is a perfect square, i.e. x = m2 for some positive integer m. Additionally, after each move, if ZS the Coder is at level k, and the number on the screen is m, then m must be a multiple of k. Note that this condition is only checked after performing the press. For example, if ZS the Coder is at level 4 and current number is 100, he presses the '<image>' button and the number turns into 10. Note that at this moment, 10 is not divisible by 4, but this press is still valid, because after it, ZS the Coder is at level 5, and 10 is divisible by 5. ZS the Coder needs your help in beating the game — he wants to reach level n + 1. In other words, he needs to press the '<image>' button n times. Help him determine the number of times he should press the ' + ' button before pressing the '<image>' button at each level. Please note that ZS the Coder wants to find just any sequence of presses allowing him to reach level n + 1, but not necessarily a sequence minimizing the number of presses. Input The first and only line of the input contains a single integer n (1 ≤ n ≤ 100 000), denoting that ZS the Coder wants to reach level n + 1. Output Print n non-negative integers, one per line. i-th of them should be equal to the number of times that ZS the Coder needs to press the ' + ' button before pressing the '<image>' button at level i. Each number in the output should not exceed 1018. However, the number on the screen can be greater than 1018. It is guaranteed that at least one solution exists. If there are multiple solutions, print any of them. Examples Input 3 Output 14 16 46 Input 2 Output 999999999999999998 44500000000 Input 4 Output 2 17 46 97 Note In the first sample case: On the first level, ZS the Coder pressed the ' + ' button 14 times (and the number on screen is initially 2), so the number became 2 + 14·1 = 16. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 16 times, so the number becomes 4 + 16·2 = 36. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. After that, on the third level, ZS pressed the ' + ' button 46 times, so the number becomes 6 + 46·3 = 144. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 12 is indeed divisible by 4, so ZS the Coder can reach level 4. Also, note that pressing the ' + ' button 10 times on the third level before levelling up does not work, because the number becomes 6 + 10·3 = 36, and when the '<image>' button is pressed, the number becomes <image> and ZS the Coder is at Level 4. However, 6 is not divisible by 4 now, so this is not a valid solution. In the second sample case: On the first level, ZS the Coder pressed the ' + ' button 999999999999999998 times (and the number on screen is initially 2), so the number became 2 + 999999999999999998·1 = 1018. Then, ZS the Coder pressed the '<image>' button, and the number became <image>. After that, on the second level, ZS pressed the ' + ' button 44500000000 times, so the number becomes 109 + 44500000000·2 = 9·1010. Then, ZS pressed the '<image>' button, levelling up and changing the number into <image>. Note that 300000 is a multiple of 3, so ZS the Coder can reach level 3. Submitted Solution: ``` import itertools n = int(input()) a = [4, ] for i in itertools.count(1,1): if len(a) == n: break if not (i ** 2 - int(a[-1] ** (1/2))) % (len(a) + 1) and not (i ** 2) % (len(a) + 2) and not i % (len(a) + 2): a.append(i ** 2) print(a) b = [2, ] for i in range(len(a) - 1): b.append(int(a[i+1] - (a[i] ** (1/2))) // (i + 2)) print(*b, sep='\n') ```
instruction
0
27,048
20
54,096
No
output
1
27,048
20
54,097
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,049
20
54,098
Tags: *special Correct Solution: ``` lst=[4,22,27,58,85,94,121,166,202,265,274,319,346,355,378,382,391,438,454,483,517,526,535,562,576,588,627,634,636,645,\ 648,654,663,666,690,706,728,729,762,778,825,852,861,895,913,915,922,958,985,1086,1111,1165] n=int(input()) print(lst[n-1]) #ppp ```
output
1
27,049
20
54,099
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,050
20
54,100
Tags: *special Correct Solution: ``` a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165] x=int(input()) print(a[x-1]) ```
output
1
27,050
20
54,101
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,051
20
54,102
Tags: *special Correct Solution: ``` print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728)[int(input())-1]) ```
output
1
27,051
20
54,103
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,052
20
54,104
Tags: *special Correct Solution: ``` a = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165] n = int(input()) - 1 print(a[n]) ```
output
1
27,052
20
54,105
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,053
20
54,106
Tags: *special Correct Solution: ``` #-------------Program-------------- #----Kuzlyaev-Nikita-Codeforces---- #-------------Training------------- #---------------------------------- r=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165] n=int(input()) print(r[n-1]) ```
output
1
27,053
20
54,107
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,054
20
54,108
Tags: *special Correct Solution: ``` L=[0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165] print(L[int(input())]) ```
output
1
27,054
20
54,109
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,055
20
54,110
Tags: *special Correct Solution: ``` a=[4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985] b=int(input()) print (a[b-1]) ```
output
1
27,055
20
54,111
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27
instruction
0
27,056
20
54,112
Tags: *special Correct Solution: ``` print((4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165)[int(input())-1]) ```
output
1
27,056
20
54,113
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,112
20
54,224
Tags: implementation Correct Solution: ``` from math import * n, k = map(int, input().split ()) while k > 0: if n % 10 == 0: n /= 10 else: n -= 1 k -= 1 print(int(n)) ```
output
1
27,112
20
54,225
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,113
20
54,226
Tags: implementation Correct Solution: ``` n, k = [int(s) for s in input().split()] for _ in range(k): if n % 10 != 0: n -= 1 else: n //= 10 print(n) ```
output
1
27,113
20
54,227
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,114
20
54,228
Tags: implementation Correct Solution: ``` n,k=map(int,input().split()) for i in range(k): if (n%10)==0: n/=10 else: n-=1 print(int(n)) ```
output
1
27,114
20
54,229
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,115
20
54,230
Tags: implementation Correct Solution: ``` a = input().split() n = int(a[0]) k = int(a[1]) for i in range(k): if str(n)[-1] == '0': n = n // 10 else: n -= 1 print(n) ```
output
1
27,115
20
54,231
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,116
20
54,232
Tags: implementation Correct Solution: ``` n,k=map(int,input().split()) for i in range(k): n = (n%10==0)*(n/10)+((n-1)*(n%10>0)) print (int(n)) ```
output
1
27,116
20
54,233
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,117
20
54,234
Tags: implementation Correct Solution: ``` n, k = input().split(" ") n = int(n) k = int(k) for i in range(1, k +1 ): if n % 10 == 0 : n = n/10 else: n =n -1 k +=1 print(int(n)) ```
output
1
27,117
20
54,235
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,118
20
54,236
Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) r = 0 for i in range(k): if n % 10: n -= 1 else: n //= 10 print(n) ```
output
1
27,118
20
54,237
Provide tags and a correct Python 3 solution for this coding contest problem. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50.
instruction
0
27,119
20
54,238
Tags: implementation Correct Solution: ``` if __name__ == "__main__": n, k = map(int, input().split()) for _ in range(k): if n % 10 == 0: n //= 10 else: n -= 1 print(n) ```
output
1
27,119
20
54,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50. Submitted Solution: ``` from sys import stdin,stdout if __name__ == '__main__': n , k = map(int, stdin.readline().split()) for _ in range(k): if(n % 10 == 0): n = n // 10 else: n = n - 1 print(n) ```
instruction
0
27,120
20
54,240
Yes
output
1
27,120
20
54,241
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50. Submitted Solution: ``` s = [int(i) for i in input().split()] tot = s[0] for i in range(s[1]): if tot % 10 == 0: tot /= 10 else: tot -= 1 print(int(tot)) ```
instruction
0
27,121
20
54,242
Yes
output
1
27,121
20
54,243
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50. Submitted Solution: ``` n, k = [int(s) for s in input().split()] for i in range(k): if n % 10 > 0: n -= 1 else: n //= 10 print(n) ```
instruction
0
27,122
20
54,244
Yes
output
1
27,122
20
54,245
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50. Submitted Solution: ``` n, k = map(int, input().split()) while k > 0 : k = k - 1 if n % 10 == 0 : n //= 10 else : n = n - 1 print(n) ```
instruction
0
27,123
20
54,246
Yes
output
1
27,123
20
54,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: * if the last digit of the number is non-zero, she decreases the number by one; * if the last digit of the number is zero, she divides the number by 10 (i.e. removes the last digit). You are given an integer number n. Tanya will subtract one from it k times. Your task is to print the result after all k subtractions. It is guaranteed that the result will be positive integer number. Input The first line of the input contains two integer numbers n and k (2 ≤ n ≤ 10^9, 1 ≤ k ≤ 50) — the number from which Tanya will subtract and the number of subtractions correspondingly. Output Print one integer number — the result of the decreasing n by one k times. It is guaranteed that the result will be positive integer number. Examples Input 512 4 Output 50 Input 1000000000 9 Output 1 Note The first example corresponds to the following sequence: 512 → 511 → 510 → 51 → 50. Submitted Solution: ``` num, k = list(map(int, input().split())) for i in range(k): if(num%10 != 0): num -= 1 else: num /= 10 print(num) ```
instruction
0
27,124
20
54,248
No
output
1
27,124
20
54,249