submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s721518757
p00109
Accepted
from inspect import currentframe from sys import exit, stderr tokens = [] cur = 0 def debug(*args): names = {id(v):k for k,v in currentframe().f_back.f_locals.items()} print(', '.join(names.get(id(arg),'???') + str(id(arg)) +' = '+repr(arg) for arg in args), file=stderr) def parse_expr(): global cur if...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s578805033
p00109
Accepted
import re class Num: def __str__(self): return str(self.x) def __init__(self, value): self.x = value def __add__(self, value): return Num(self.x + value.x) def __sub__(self, value): return Num(self.x - value.x) def __mul__(self, value): return Num(self.x * val...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s647801461
p00109
Accepted
def solve(s): def expr(l): left, mid = term(l) return edum(mid, left) def edum(l, lval): if s[l] == '+': val, mid = term(l + 1) return edum(mid, lval + val) if s[l] == '-': val, mid = term(l + 1) return edum(mid, lval - val) ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s959242707
p00109
Accepted
import re import decimal def main(): decimal.getcontext().rounding = decimal.ROUND_DOWN n = int(input()) for i in range(n): s = input() s = re.sub(r'(\d+)', r'decimal.Decimal(\1)', s).replace('=', '').replace('/', '//') print(int(eval(s))) main()
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s824687420
p00109
Accepted
from collections import deque priority = {"*":1,"/":1, "+":0, "-":0, "(":-1, ")":-1} n = int(input()) for i in range(n): s = input() out = [] ope = deque([]) for j in range(len(s)): inp = s[j] if inp == "=": while len(ope): out.append(ope.pop()) ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s753440365
p00109
Accepted
import re class c: def __str__(self): return str(self.x) def __init__(self,value): self.x=value def __add__(self,value): return c(self.x+value.x) def __sub__(self,value): return c(self.x-value.x) def __mul__(self,value): return c(self.x*value.x) def __true...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s953486617
p00109
Accepted
import re class c(int): def __add__(self,n): return c(int(self)+int(n)) def __sub__(self,n): return c(int(self)-int(n)) def __mul__(self,n): return c(int(self)*int(n)) def __truediv__(self,n): return c(int(int(self)/int(n))) n = int(input()) for i in range(n): print(e...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s722833028
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp,brac=None): i = 0 # ループカウンタ? num = deque() # 数字をためておく ops = deque() # +-をためておく ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s263857037
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp,brac=None): i = 0 # ループカウンタ? num = deque() # 数字をためておく ops = deque() # +-をためておく ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s540106571
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp,brac=None): i = 0 # ループカウンタ? num = deque() # 数字をためておく ops = deque() # +-をためておく ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s366906723
p00109
Runtime Error
for _ in range( int(raw_input()) ): print int(eval( "1.0"+raw_input()[:-1] ))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s841685600
p00109
Runtime Error
def f(s): while 1: b=s.find(")") if b<0: return g(s) a=s[:b].rfind("(") s1=s[a:b+1] s=s.replace(s1,f(s1[1:-1])) def g(s): a="" f=1 x=[] def F(a,b): x.append(a) x.append(b) return 1,"" for c in s: if c=="=": continue elif c in "*/": f,a=F(a,c) elif c in "+-": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s585153471
p00109
Runtime Error
N = int(raw_input()) for loop in xrange(N): print eval(raw_input().replace("/","//"))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s331536662
p00109
Runtime Error
ops = {"+": lambda a, b: b + a, "-": lambda a, b: b - a, "*": lambda a, b: b * a, "/": lambda a, b: b // a} def calc(temp, v): if v in ops: temp.append(ops[v](temp.pop(), temp.pop())) else: temp.append(int(v)) return temp n = input() for i in range(n): porand = [] ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s481802056
p00109
Runtime Error
ops = {"+": lambda a, b: b + a, "-": lambda a, b: b - a, "*": lambda a, b: b * a, "/": lambda a, b: b / a} def calc(temp, v): if v in ops: temp.append(ops[v](temp.pop(), temp.pop())) else: temp.append(int(v)) return temp n = input() for i in range(n): porand = [] ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s920838947
p00109
Runtime Error
ops = {"+": lambda a, b: b + a, "-": lambda a, b: b - a, "*": lambda a, b: b * a, "/": lambda a, b: b / a, "@": lambda a, b: -(abs(int(1.0*a/b)))} def calc(temp, v): if v in ["+", "-", "*"]: temp.append(ops[v](temp.pop(), temp.pop())) elif v == "/": if temp[-1] < 0 o...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s521814293
p00109
Runtime Error
ops = {"+": lambda a, b: b + a, "-": lambda a, b: b - a, "*": lambda a, b: b * a, "/": lambda a, b: b / a, "@": lambda a, b: -(abs(int(1.0*b/a)))} def calc(stack, v): if v in ["+", "-", "*"]: stack.append(ops[v](stack.pop(), stack.pop())) elif v == "/": if stack[-1] ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s333212283
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print fx(formula) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+formu...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s446352414
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print fx(formula) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+formu...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s393635138
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print fx(formula) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+formu...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s438264538
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print fx(formula) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+formu...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s986941801
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print int(fx(formula)) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s274467754
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print fx(formula) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+formu...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s211180156
p00109
Runtime Error
def up_to_you(formula): l_p = None r_p = None for i, c in enumerate(formula): if c == '(': l_p = i elif c == ')': r_p = i break else: print fx(formula) return r = fx(formula[l_p+1:r_p]) n_formula = formula[:l_p]+r+formu...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s773755072
p00109
Runtime Error
def seekBackOperatorInLand(op,s): depth = 0 for i in xrange(len(s)-1,-1,-1): if s[i]==')': depth+=1 if s[i]=='(': depth-=1 if s[i]==op and depth==0: return i return None def calc(s): if all(map(lambda t: t in "0123456789", s)): return int(s) if s[0]=='(' and s[-1]==')' and all(map(lambda t: t!='(' and t!=...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s619365812
p00109
Runtime Error
def seekBackOperatorInLand(op,s): depth = 0 for i in xrange(len(s)-1,-1,-1): if s[i]==')': depth+=1 if s[i]=='(': depth-=1 if s[i]==op and depth==0: return i return None def calc(s): if s=='': return 0 if all(map(lambda t: t in "0123456789", s)): return int(s) p = seekBackOperatorInLand('+',s) if n...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s896865028
p00109
Runtime Error
def seekBackOperatorInLand(op,s): depth = 0 for i in xrange(len(s)-1,-1,-1): if s[i]==')': depth+=1 if s[i]=='(': depth-=1 if s[i]==op and depth==0: return i return None def calc(s): if s=='': return 0 if all(map(lambda t: t in "0123456789", s)): return int(s) p = seekBackOperatorInLand('+',s) if n...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s816895999
p00109
Runtime Error
import sys #while 1: # (a,b,c) = map(int , raw_input().split()) def isdigit2(n): n = str(n) if(n.isdigit()):return True if(n.startwith("-")): if(len(n)==1):return False if(str(n)[1:].isdigit):return True return False def parse(line): lis = [] ind =0 while(line[ind]!=...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s359850737
p00109
Runtime Error
def parse(line): lis = [] ind =0 while(line[ind]!="="): a = line[ind] if(a.isdigit()==False): lis.append(a) ind+=1 continue else: s=ind while(line[ind].isdigit()):ind+=1 lis.append(line[s:ind]) contin...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s955459091
p00109
Runtime Error
def parse(line): lis = [] ind =0 while(line[ind]!="="): a = line[ind] if(ind==0 and a=="-"): s=ind ind += 1 while(line[ind].isdigit()):ind+=1 lis.append(int(line[s:ind])) continue if(a.isdigit()==False): lis.app...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s071894126
p00109
Runtime Error
# ????????±?????¬??§??????????????????[l, r)??§?????? def getLR(li): l, r = 0, 0 for i in range(len(li)): if li[i] == "(": l = i if li[i] == ")": r = i + 1 return l, r return l, r # li????¨?????????????????????????(li?????¬??§???????????????) def calc(li)...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s459740174
p00109
Runtime Error
def getLR(li): l, r = 0, 0 for i in range(len(li)): if li[i] == "(": l = i if li[i] == ")": r = i + 1 return l, r return l, r def calc(li): # *, / t_li = [] while True: for i in range(len(li) - 2): if li[i + 1] == "*": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s827224095
p00109
Runtime Error
def f1(line): p = None q = None for i, s in enumerate(line): if s == '(': p = i elif s == ')': q = i if q: break else: return f2(line) before = line[:p] after = line[q + 1:] x = f2(line[p + 1:q]) return f1(before + str(x...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s071474144
p00109
Runtime Error
def f1(line): p = None q = None for i, s in enumerate(line): if s == '(': p = i elif s == ')': q = i if q: break else: return f2(line) before = line[:p] after = line[q + 1:] x = f2(line[p + 1:q]) return f1(before + str(x...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s410795361
p00109
Runtime Error
def f1(line): p = None q = None for i, s in enumerate(line): if s == '(': p = i elif s == ')': q = i if q: break else: return f2(line) before = line[:p] after = line[q + 1:] x = f2(line[p + 1:q]) return f1(before + str(x...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s544155368
p00109
Runtime Error
inputs=[] while True: try: inputs.append(input()) except EOFError: break for i in inputs: a,c=i.split("=") a,b=a.split("+") # a+b=c for x in range(0,10): if x==0 and (a[0]=="X" or b[0]=="X" or c[0]=="X"): next A=a.replace("X",str(x)) B=b.replace("X",str(x)) C=c.replace("X",s...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s150138173
p00109
Runtime Error
def calc(eqt): l = eqt.split("+",maxsplit=1) if len(l) == 2: return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2: return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2: return (calc(l[0])*calc(l[1])) l = eqt.split("/",maxsplit=1) if len(l) == 2: ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s291368837
p00109
Runtime Error
def calc(eqt): l = eqt.split("+",maxsplit=1) if len(l) == 2: return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2: return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2: return (calc(l[0])*calc(l[1])) l = eqt.split("/",maxsplit=1) if len(l) == 2: ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s458525134
p00109
Runtime Error
def calc(eqt): l = eqt.split("+",maxsplit=1) if len(l) == 2: return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2: return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2: return (calc(l[0])*calc(l[1])) l = eqt.split("/",maxsplit=1) if len(l) == 2: ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s450391715
p00109
Runtime Error
def calc(eqt): l = eqt.split("+",maxsplit=1) if len(l) == 2: return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2: return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2: return (calc(l[0])*calc(l[1])) l = eqt.split("/",maxsplit=1) if len(l) == 2: ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s046379636
p00109
Runtime Error
def calc(eqt): # assuming that eqt has no brackets. l = eqt.split("+",maxsplit=1) if len(l) == 2: # if eqt has "+", then return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2:# if eqt has "-", then return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2:# if...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s307389784
p00109
Runtime Error
def calc(eqt): # assuming that eqt has no brackets. l = eqt.split("+",maxsplit=1) if len(l) == 2: # if eqt has "+", then return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2:# if eqt has "-", then return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2:# if...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s037737420
p00109
Runtime Error
def calc(eqt): # assuming that eqt has no brackets. l = eqt.split("+",maxsplit=1) if len(l) == 2: # if eqt has "+", then return (calc(l[0])+calc(l[1])) l = eqt.split("-",maxsplit=1) if len(l) == 2:# if eqt has "-", then return (calc(l[0])-calc(l[1])) l = eqt.split("*",maxsplit=1) if len(l) == 2:# if...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s866235860
p00109
Runtime Error
#n=int(input()) def lastfind(s,x): n=len(s) s_rev=s[::-1] t=s_rev.find(x) return n-t-1 def doublefind(s,x,y): if x in s: p=s.find(x) else: p=len(s)+10 if y in s: q=s.find(y) else: q=len(s)+10 if p<=q and p<len(s)+5: return [p,x] elif ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s555721813
p00109
Runtime Error
#n=int(input()) def lastfind(s,x): n=len(s) s_rev=s[::-1] t=s_rev.find(x) return n-t-1 def doublefind(s,x,y): if x in s: p=s.find(x) else: p=len(s)+10 if y in s: q=s.find(y) else: q=len(s)+10 if p<=q and p<len(s)+5: return [p,x] elif ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s850605114
p00109
Runtime Error
#n=int(input()) def lastfind(s,x): n=len(s) s_rev=s[::-1] t=s_rev.find(x) return n-t-1 def doublefind(s,x,y): if x in s: p=lastfind(s,x) else: p=-1 if y in s: q=lastfind(s,y) else: q=-1 if p==-1 and q==-1: return 0 elif p<=q: ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s985912227
p00109
Runtime Error
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp """ import sys import re def solve(exp): exp = exp.replace('=', '') exp = exp.replace('/', '//') return eval(exp) def solve2(exp): exp = exp.replace('=', '') p = re.compile('(-*\d)/(\d)') return...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s105835618
p00109
Runtime Error
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp """ import sys import re def solve(exp): exp = exp.replace('=', '') exp = exp.replace('/', '//') return eval(exp) def solve2(exp): exp = exp.replace('=', '') p = re.compile('(\d)/(\d)') return e...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s293855145
p00109
Runtime Error
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp """ import sys from sys import stdin import re input = stdin.readline class SmartInt(int): def __truediv__(self, other): sign = 1 if self.n < 0: sign = -1 self.n *= -1 ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s354094464
p00109
Runtime Error
n = int(input()) for i in range(n): eq = input().replace("=","") print(eval(eq))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s982645727
p00109
Runtime Error
n = int(input()) for i in range(n): eq = input().replace("/","//") print(eval(eq))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s998695737
p00109
Runtime Error
n = int(input()) for i in range(n): eq = input().replace("/","//").replace("=","") print(eval(eq))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s922960552
p00109
Runtime Error
import re #from me.io import dup_file_stdin #@dup_file_stdin def solve(): for _ in range(int(sys.stdin.readline())): expr = sys.stdin.readline()[:-1].strip("=") expr = re.sub(".d+","",expr) print(eval(expr.replace("/","//"))) solve()
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s988400481
p00109
Runtime Error
# coding: utf-8 # Convert String to List def String2List(s): L = []; tmp = "" for i in s: if i.isdigit(): tmp += i else: if tmp != "": L.append(tmp) tmp = "" L.append(i) if tmp != "": L.append(tmp) return L # ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s378867829
p00109
Runtime Error
# coding: utf-8 # Convert String to List def String2List(s): L = []; tmp = "" for i in s: if i.isdigit(): tmp += i else: if tmp != "": L.append(tmp) tmp = "" L.append(i) if tmp != "": L.append(tmp) return L # ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s109811375
p00109
Runtime Error
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] inputCountent = string[:-1] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while si...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s609592720
p00109
Runtime Error
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s359463605
p00109
Runtime Error
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s877131568
p00109
Runtime Error
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s727218689
p00109
Runtime Error
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s524729517
p00109
Runtime Error
def ReversePolishNotation(string): priority = {"Sentinel": 0, "(": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = ["Sentinel"] for item in string[:-1]: if item == "(": signStack.append(item) elif item == ")": while signStack[-1] != "(": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s762332256
p00109
Runtime Error
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0} for _ in[0]*int(input()): L=[];t='' for e in input()[:-1]: if e.isdigit():t+=e else: if t:L+=[t];t='' L+=e if t:L+=[t] P,S=[],[] for i in L: if"("==i:S+=i elif")"==i: while"("!=S[-1]:P+=S.pop() S.pop() elif i in R: while S and R[S[-1]]>=R[i]:P+=S.pop...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s236138628
p00109
Runtime Error
R={"*":2,"/":2,"+":1,"-":1,"(":0,")":0} for _ in[0]*int(input()): L=[];t='' for e in input()[:-1]: if e.isdigit():t+=e else: if t:L+=[t];t='' L+=e if t:L+=[t] P,S=[],[] for i in L: if"("==i:S+=i elif")"==i: while"("!=S[-1]:P+=S.pop() S.pop() elif i in R: while S and R[S[-1]]>=R[i]:P+=S.pop...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s147411365
p00109
Runtime Error
# -*- coding: utf-8 -*- # 写経した import re class Num: def __str__(self): return str(self.x) def __init__(self, value): self.x = value def __add__(self, value): return o(self.x + value.x) def __sub__(self, value): return o(self.x - value.x) def __mul__(self, value): ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s466199161
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): print("calculate",exp) i = 0 num = deque() ops = deque() ope = "" w...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s461454373
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s635276299
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s461424390
p00109
Runtime Error
from collections import deque from sys import stderr from functools import reduce from operator import add def f(): return [int(i) for i in input().split()] def debug(*x, sep=" ", end="\n"): for item in x: stderr.write(repr(item)) stderr.write(sep) stderr.write(end) def eva(l, r, op): if o...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s177245982
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s742216560
p00109
Runtime Error
from collections import deque from sys import stderr def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): stderr.write(exp) i = 0 num = deque() ops = deque()...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s700038898
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s464216994
p00109
Runtime Error
from collections import deque def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" while i < len(exp): ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s139144764
p00109
Runtime Error
from collections import deque from sys import stderr def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): stderr.write(exp) i = 0 num = deque() ops = deque()...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s834694677
p00109
Runtime Error
from collections import deque from sys import stderr def eva(l, r, op): if op == "+": return l + r elif op == "-": return l - r elif op == "*": return l * r elif op == "/": return l // r def calc(exp): i = 0 num = deque() ops = deque() ope = "" whil...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s822307560
p00109
Runtime Error
from collections import deque from sys import stderr from functools import reduce from operator import add def f(): return [int(i) for i in input().split()] def debug(*x, sep=" ", end="\n"): for item in x: stderr.write(repr(item)) stderr.write(sep) stderr.write(end) def eva(l, r, op): if ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s242218788
p00109
Runtime Error
for i in range(input()): print int((eval("".join([str(float(i)) if i.isdigit() else i for i in raw_i\ nput() if i!="="]))))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s752250090
p00109
Runtime Error
for i in range(input()): print int((eval("".join([str(float(i)) if i.isdigit() else i for i in raw_input() if i!="="]))))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s801718545
p00109
Runtime Error
for i in range(input()): s=raw_input()[:-1] s="".join(str(float(i)) if i.isdigit() else i for i in s) print int(eval(s))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s808953548
p00109
Runtime Error
def rank(ch,st): dic={"+":1,"-":1,"*":3,"/":2,"(":0} return dic[ch]<dic[st] for i in range(input()): s=raw_input()[:-1] buf=[] stack=[] for ch in s: if ch.isdigit(): buf.append(ch) elif ch==")": temp=stack.pop() while temp!="(": ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s359500720
p00109
Runtime Error
def rank(ch,st): dic={"+":1,"-":1,"*":2,"/":2,"(":0,")":0} return dic[ch]<=dic[st] for i in range(input()): s=raw_input()[:-1] buf=[] stack=[] for ch in s: if ch.isdigit(): buf.append(ch) elif ch=="(": stack.append(ch) elif ch==")": te...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s252968248
p00109
Runtime Error
from __future__ import division for i in range(input()): s=raw_input()[:-1] t="" for ch in s: if ch.isdigit(): t+=str(float(ch)) elif ch=="/": t+="//" else: t+=ch print int(eval(t))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s241930677
p00109
Runtime Error
while True: n = int(raw_input()) if n == 0: break for i in range(n): print eval(raw_input().strip()[:-1])
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s733087246
p00109
Runtime Error
import sys while True: line = raw_input() if line == '': break for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) sys.stderr.writelines(a)
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s914478368
p00109
Runtime Error
import sys while True: line = raw_input() if line == '': break for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) sys.stderr.write(a)
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s654373798
p00109
Runtime Error
anb2 = lambda a,b: -(abs(int(1.0*a/b))) def number(begin): global i if begin[i] == "(": i += 1 res = expression(begin) i += 1 return res res = 0 while begin[i].isdigit(): res *= 10 res += int(begin[i]) i+=1 return res def term(begin):# your code goes here global i res = number(begin) ...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s964079119
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: return [_src[0]] + _split(_src[1:]) else: return [int(_src[:c])] + _split...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s245891549
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if tmp != [] and tmp[0] == "-": tmp = ["+" , "(", 0 , "-...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s006209763
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit(0) return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s703828457
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit(0) return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s462809919
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit(0) return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s988130655
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit() return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s926768218
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit() return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: return [_src[0...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s793684690
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 if x == 0:exit() return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s345514936
p00109
Runtime Error
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s def _split(_src): c = 0 l = len(_src) if l == 0: return [] while c < l and ord('0') <= ord(_src[c]) <= ord('9'): c += 1 if c == 0: tmp = _split(_src[1:]) if t...
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s852341959
p00109
Runtime Error
for i in xrange(input()): print int(eval(raw_input().strip().strip('=').replace('/','.0/')))
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s420509837
p00109
Runtime Error
T = int(input()) for tc in range(0,T) : print input().strip("=")
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s375724619
p00109
Runtime Error
import sys for exp in sys.stdin: if exp[-1] == '=': print eval(exp[1:]) else: print eval(exp)
2 4-2*3= 4*(8+4+3)=
-2 60
<H1>Smart Calculator</H1> <p> Your task is to write a program which reads an expression and evaluates it. </p> <ul> <li>The expression consists of numerical values, operators and parentheses, and the ends with '='.</li> <li>The operators includes +, - , *, / where respectively represents, addition, subtraction, mul...
s308066780
p00110
Wrong Answer
while True: try: s = input().replace('=', '==') except EOFError: break for x in '0123456789': t = s.replace('X', x) if t[0] == '0' or t[t.index('+')+1] == '0' or t[t.index('=')+2] == '0': continue if eval(t): print(x) break els...
123+4X6=X79 12X+4X6=X79 XX22+89=X2XX
5 NA 1
<H1>覆面算</H1> <p> 数式の一部を隠してしまって、隠した数字を探す問題を覆面算といいます。今回は、数式の中のある数字のいくつかを X で隠してしまった式を扱います。以下の数式を入力して、結果を出力するプログラムを作成してください。 </p> <p> 数式</p> <ul> <li>「数字列 + 数字列 = 数字列」の形で、1 行の単純な足し算式です。</li> <li> 「数字列」は、数字 0 から 9 と文字 X の並びです。</li> <!--<li> 「数字列」は、8 桁以下の整数を表すものとします。</li>--> <li> 2 桁以上の「数字列」の左端の数字は 0 ではないものとします。</li>...
s697149416
p00110
Wrong Answer
while(True): try: a,b = input().split("=") for i in range(10): if not i and len([1 for c in a.split("+") if c[0]=="X" ]): continue if eval(a.replace("X",str(i))) == int(b.replace("X",str(i))): print(i) break else: ...
123+4X6=X79 12X+4X6=X79 XX22+89=X2XX
5 NA 1
<H1>覆面算</H1> <p> 数式の一部を隠してしまって、隠した数字を探す問題を覆面算といいます。今回は、数式の中のある数字のいくつかを X で隠してしまった式を扱います。以下の数式を入力して、結果を出力するプログラムを作成してください。 </p> <p> 数式</p> <ul> <li>「数字列 + 数字列 = 数字列」の形で、1 行の単純な足し算式です。</li> <li> 「数字列」は、数字 0 から 9 と文字 X の並びです。</li> <!--<li> 「数字列」は、8 桁以下の整数を表すものとします。</li>--> <li> 2 桁以上の「数字列」の左端の数字は 0 ではないものとします。</li>...
s479663846
p00110
Wrong Answer
while(True): try: a,b = input().split("=") for i in range(10): if not i and (len([1 for c in a.split("+") if c[0]=="X"]) or b[0]=="X"): continue if eval(a.replace("X",str(i))) == int(b.replace("X",str(i))): print(i) break ...
123+4X6=X79 12X+4X6=X79 XX22+89=X2XX
5 NA 1
<H1>覆面算</H1> <p> 数式の一部を隠してしまって、隠した数字を探す問題を覆面算といいます。今回は、数式の中のある数字のいくつかを X で隠してしまった式を扱います。以下の数式を入力して、結果を出力するプログラムを作成してください。 </p> <p> 数式</p> <ul> <li>「数字列 + 数字列 = 数字列」の形で、1 行の単純な足し算式です。</li> <li> 「数字列」は、数字 0 から 9 と文字 X の並びです。</li> <!--<li> 「数字列」は、8 桁以下の整数を表すものとします。</li>--> <li> 2 桁以上の「数字列」の左端の数字は 0 ではないものとします。</li>...