submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s068152643
p00109
Wrong Answer
def calc(a,b,op): if op == "+": return b+a if op == "-": return b-a if op == "*": return b*a if op == "/": return b/a def RPN(reg): OP = ["+","-","*","/"] stack = [] for r in reg: if r in OP: stack.append(calc(stack.pop(),stack.pop(),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...
s576401787
p00109
Wrong Answer
n = input() for _t in range(n): print eval(raw_input().rstrip("="))
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...
s815731820
p00109
Wrong Answer
n = input() for _t in range(n): print int(eval("float("+raw_input().rstrip("=")+")") + 1e-16)
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...
s357621297
p00109
Wrong Answer
for i in range(input()): print eval(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...
s451001093
p00109
Wrong Answer
for i in range(input()): exec "c="+raw_input()[:-1] print c
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...
s710980602
p00109
Wrong Answer
n=input() for i in range(n): print eval(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...
s697517358
p00109
Wrong Answer
for i in range(input()): print eval("".join([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...
s673932560
p00109
Wrong Answer
from __future__ import division for i in range(input()): print int(eval(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...
s660648048
p00109
Wrong Answer
import sys def solv(expr): expr = expr.rstrip('=') return eval(expr) while True: try: n = int(sys.stdin.readline()) for i in range(n): expr = sys.stdin.readline().rstrip('\n') print solv(expr) except: exit()
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...
s515079603
p00109
Wrong Answer
import sys class Scanner: def __init__(self, str): str = str.rstrip('=') str = '(' + str + ')' self.tokens = self.tokenize(str) def tokenize(self, str): x = list(str) t = [] while True: if not x: break c = x.pop(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...
s342968402
p00109
Wrong Answer
import sys import math class Scanner: def __init__(self, str): str = str.rstrip('=') str = '(' + str + ')' self.tokens = self.tokenize(str) def tokenize(self, str): x = list(str) t = [] while True: if not x: break c = 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...
s029958154
p00109
Wrong Answer
while True: line = raw_input() if line == '': break n = int(line) 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...
s840341060
p00109
Wrong Answer
while True: line = raw_input() if line == '': break n = int(line) for i in range(n): print eval(raw_input().replace('/', '//')[:-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...
s382029215
p00109
Wrong Answer
while True: line = raw_input() if line == '': break n = int(line) for i in range(n): print int(eval(raw_input().replace('/', '//')[:-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...
s414077405
p00109
Wrong Answer
while True: line = raw_input() if line == '': break for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) print int(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...
s657390763
p00109
Wrong Answer
import sys while True: line = raw_input() if line == '': break for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) print(str(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...
s869137393
p00109
Wrong Answer
for i in range(input()): s=raw_input() s=s.replace("/","//") print eval(s[:-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...
s651150791
p00109
Wrong Answer
import re def expression(): global pos ret=term() while True: if L[pos]=="+": pos+=1 ret+=term() elif L[pos]=="-": pos+=1 ret-=term() else: break return ret def term(): global pos ret=factor() while 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...
s311559900
p00109
Wrong Answer
import re def expression(): global pos ret=term() while True: if L[pos]=="+": pos+=1 ret+=term() elif L[pos]=="-": pos+=1 ret-=term() else: break return ret def term(): global pos ret=factor() while 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...
s748424744
p00109
Wrong Answer
def expression(): global pos ret=term() while True: if L[pos]=="+": pos+=1 ret+=term() elif L[pos]=="-": pos+=1 ret-=term() else: break return ret def term(): global pos ret=factor() while True: if 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...
s128398994
p00109
Wrong Answer
i = 0 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) while True: if begin[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...
s600761693
p00109
Wrong Answer
i = 0 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) while True: if begin[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...
s299542628
p00109
Wrong Answer
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) while True: if begin[i] == "*": 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...
s711476327
p00109
Wrong Answer
n = int(raw_input()) for _ in range(n): print eval(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...
s391375654
p00109
Wrong Answer
import re def factor(t, i): if t[i[0]] == '(': i[0] += 1 return expr(t, i) else: r = int(t[i[0]]) i[0] += 1 return r def term(t, i): r = factor(t, i) while True: if t[i[0]] == '*': i[0] += 1 r *= factor(t, i) elif t[i[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...
s675936966
p00109
Wrong Answer
import re def factor(t, i): if t[i[0]] == '(': i[0] += 1 r = expr(t, i) i[0] += 1 return r else: i[0] += 1 return int(t[i[0]-1]) def term(t, i): r = factor(t, i) while True: if t[i[0]] == '*': i[0] += 1 r *= factor(t, 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...
s652450318
p00109
Wrong Answer
import re def factor(t, i): if t[i[0]] == '(': i[0] += 1 r = expr(t, i) i[0] += 1 return r else: i[0] += 1 return int(t[i[0]-1]) def term(t, i): r = factor(t, i) while True: if t[i[0]] == '*': i[0] += 1 r *= factor(t, 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...
s257382754
p00109
Wrong Answer
for t in xrange(input()): print eval(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...
s356328296
p00109
Wrong Answer
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...
s346210171
p00109
Wrong Answer
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:])...
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...
s668157421
p00109
Wrong Answer
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:]...
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...
s983542950
p00109
Wrong Answer
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:]...
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...
s244647293
p00109
Wrong Answer
import sys for s in sys.stdin: if '=' in s: print eval(s.strip().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...
s251656391
p00109
Wrong Answer
import sys for s in sys.stdin: if '=' in s: print int(eval(s.strip().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...
s413143032
p00109
Wrong Answer
for i in xrange(input()): print int(eval(raw_input().strip().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...
s424303563
p00109
Wrong Answer
for i in xrange(input()): print int(eval(raw_input().strip().strip('=').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...
s807271921
p00109
Wrong Answer
#!/usr/bin/env python from __future__ import division, print_function from sys import stdin, exit def main(readline=stdin.readline): n = int(readline()) for _ in range(n): print(eval(readline().replace('/', '//').replace('=', ''))) exit() if __name__ == '__main__': 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...
s402363023
p00109
Wrong Answer
#!/usr/bin/env python from __future__ import division, print_function from sys import stdin, exit from operator import add, sub, mul, floordiv OPERATOR = {'+': add, '-': sub, '*': mul, '/': floordiv} class Parser(list): """ <statement> ::= <expression> "=" <expression> ::= <term> [ ("+"|"-") <term> ] ...
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...
s591417492
p00109
Wrong Answer
n = input() for i in range(n): str = raw_input()[:-1] print eval(str)
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...
s227588387
p00109
Wrong Answer
n = int(raw_input()) for i in range(n): e = raw_input() print eval(e[:len(e)-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...
s040713090
p00109
Wrong Answer
n = int(raw_input()) for i in range(n): e = map(str, raw_input().split("/")) a = "//".join(map(str, e)) print eval(a[:len(a)-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...
s639744219
p00109
Wrong Answer
n = int(raw_input()) for i in range(n): e = map(str, raw_input().split("/")) a = "//".join(map(str, e)) print eval(a[:-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...
s908642282
p00109
Wrong Answer
n = int(raw_input()) for i in range(n): a = raw_input() print eval(a[:-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...
s141987613
p00109
Wrong Answer
n = input() for i in range(n): print eval(raw_input().replace("/","//")[:-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...
s343124689
p00109
Wrong Answer
T = int(input()) for tc in range(0,T) : print(eval(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...
s197553394
p00109
Wrong Answer
T = int(input()) for tc in range(0,T) : print(int(eval(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...
s256903990
p00109
Wrong Answer
T = int(input()) for tc in range(0,T) : print eval(raw_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...
s882722582
p00109
Wrong Answer
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...
s549341909
p00109
Wrong Answer
T = int(input()) for tc in range(0,T) : print(int(eval(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...
s077931702
p00109
Wrong Answer
T = int(input()) for tc in range(0,T) : print int(eval(raw_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...
s651054825
p00109
Wrong Answer
T = int(input()) for tc in range(0,T) : print int(eval(raw_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...
s694934023
p00109
Wrong Answer
s = ""; l = 0; def expr(idx): ret, idx = term(idx) while idx<l: if s[idx]=='+': r, idx = term(idx+1) ret += r elif s[idx]=='-': r, idx = term(idx+1) ret -= r else: break return ret, idx def term(idx): ret, idx = fac...
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...
s688101816
p00109
Wrong Answer
n = int(raw_input()) while n: s = raw_input() print eval(s[:-1]) 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...
s462603682
p00109
Time Limit Exceeded
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...
s341077232
p00109
Time Limit Exceeded
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...
s070998524
p00109
Time Limit Exceeded
def calc(array): while not len(array) == 1: if '*' in array: x = array.index('*') array[x + 1] = str(int(array[x - 1]) * int(array[x + 1])) del array[x - 1:x + 1] continue if '/' in array: x = array.index('/') array[x + 1] = str(int(array[x - 1]) / int(array[x + 1])) del array[x - 1:x + 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...
s038984908
p00109
Time Limit Exceeded
def calc(array): while len(array) > 1: if '/' in array: c = array.index('/') array[c + 1] = array[c - 1] / array[c + 1] del array[c - 1:c + 1] continue if '*' in array: c = array.index('*') array[c + 1] = array[c - 1] * array[c + 1] del array[c - 1:c + 1] continue if '-' in array: c = ...
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...
s625285201
p00109
Time Limit Exceeded
def calc(array): while len(array) > 1: if '/' in array: c = array.index('/') array[c + 1] = array[c - 1] / array[c + 1] del array[c - 1:c + 1] continue if '*' in array: c = array.index('*') array[c + 1] = array[c - 1] * array[c + 1] del array[c - 1:c + 1] continue if '-' in array: c = ...
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...
s291119460
p00109
Time Limit Exceeded
def calc(array): while len(array) > 1: if '/' in array: c = array.index('/') array[c + 1] = array[c - 1] / array[c + 1] del array[c - 1:c + 1] elif '*' in array: c = array.index('*') array[c + 1] = array[c - 1] * array[c + 1] del array[c - 1:c + 1] elif '-' in array: c = array.index('-') ...
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...
s254723412
p00109
Time Limit Exceeded
def calc(array): while '(' in array: c1 = array.index('(') c2 = array.index(')') array[c2] = calc(array[c1 + 1:c2]) del array[c1:c2] while len(array) > 1: if '/' in array: c = array.index('/') array[c + 1] = array[c - 1] / array[c + 1] del array[c - 1:c + 1] elif '*' in array: c = array.index(...
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...
s577188337
p00109
Time Limit Exceeded
def calc(array): while '(' in array: c1 = array.index('(') c2 = array.index(')') array[c2] = calc(array[c1 + 1:c2]) del array[c1:c2] while len(array) > 1: if '/' in array: c = array.index('/') array[c + 1] = int(array[c - 1] / array[c + 1]) del array[c - 1:c + 1] elif '*' in array: c = array.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...
s417825673
p00109
Time Limit Exceeded
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...
s687818308
p00109
Time Limit Exceeded
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): try: 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...
s873173218
p00109
Time Limit Exceeded
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(str(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...
s194560478
p00109
Time Limit Exceeded
import sys while True: line = raw_input() if line == '': break sys.stderr.write(line) for i in range(int(line)): a = eval(raw_input().replace('/', '//')[:-1]) print(str(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...
s722455688
p00109
Accepted
def digit(): global S global cur if S[cur].isdigit(): n = int(S[cur]) cur += 1 return n def number(): global S L = len(S) global cur n = digit() while (cur < L and S[cur].isdigit()): n = n*10 + digit() return n def expression(): global S global...
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...
s580241083
p00109
Accepted
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...
s472237403
p00109
Accepted
def f(s): while 1: b=s.find(")") if b<0: return g(s) a=s[:b].rfind("(") s=s.replace(s[a:b+1],f(s[a+1:b])) 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 "+-": if f==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...
s554914861
p00109
Accepted
def f(s): while 1: b=s.find(")") if b<0: return g(s) a=s[:b].rfind("(") s=s.replace(s[a:b+1],f(s[a+1:b])) 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 "+-": if f==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...
s674868114
p00109
Accepted
#!/usr/bin/python3 import re class Num: def __init__(this, x): this.x = x def __str__(this): return str(this.x) def __add__(this, that): return Num(this.x + that.x) def __sub__(this, that): return Num(this.x - that.x) def __truediv__(this, that): 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...
s713880707
p00109
Accepted
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+formula[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...
s861048070
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 __truediv__(self,value): return c(int(self.x/value.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...
s911414518
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))) for _ in range(int(input())): print(eval...
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...
s011042776
p00109
Accepted
# -*- coding: utf-8 -*- import sys import os import math 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) ...
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...
s649653277
p00109
Accepted
def String2List(s): L = [] flag = True l = len(s) for i in range(l): if s[i].isdigit() and flag: t = "" j = 0 while s[i+j].isdigit(): t += s[i+j] if i+j == l-1: break j += 1 L.appe...
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...
s178581054
p00109
Accepted
def String2List(s): L = [] flag = True l = len(s) for i in range(l): if s[i].isdigit() and flag: t = "" j = 0 while s[i+j].isdigit(): t += s[i+j] if i+j == l-1: break j += 1 L.appe...
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...
s927113497
p00109
Accepted
def String2List(s): L = [] flag = True l = len(s) for i in range(l): if s[i].isdigit() and flag: t = "" j = 0 while s[i+j].isdigit(): t += s[i+j] if i+j == l-1: break j += 1 L.appe...
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...
s757593631
p00109
Accepted
import re class Num: def __init__(self, x): self.x = x def __str__(self): return str(self.x) def __add__(self, other): return Num(self.x + other.x) def __sub__(self, other): return Num(self.x - other.x) def __truediv__(self, other): return Num(int(self.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...
s107157585
p00109
Accepted
# 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...
s994852280
p00109
Accepted
import sys #from me.io import dup_file_stdin def prec(op): if op in "+-":return 1 if op in "*/":return 2 raise NotImplementedError() def postFix(expr): stack = [] operators = [] num = 0 isdigit = False for ch in expr: if ch.isdigit(): isdigit = 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...
s338953709
p00109
Accepted
def ReversePolishNotation(string): priority = {"(": 0, ")": 0, "+": 1, "-": 1, "*": 2, "/": 2} stack = [] signStack = [] isContinue = False for item in string[:-1]: if str.isdigit(item): if not isContinue: stack.append(item) isContinue = 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...
s969444263
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))) for _ in[0]*int(input()):print(eval(re.sub(r'(\d+)',r'c(\1)',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...
s576079954
p00109
Accepted
import re class c: def __init__(self,value):self.x=value def __str__(self):return str(self.x) 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 __truediv__(self,value):return c(int(self.x/value.x)) for i in[0]*int...
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...
s255199840
p00109
Accepted
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...
s866047446
p00109
Accepted
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...
s122206180
p00109
Accepted
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...
s040050709
p00109
Accepted
def get_input(): while True: try: yield ''.join(input()) except EOFError: break # Convert String to List def String2List(s): L = []; tmp = "" for i in s: if i.isdigit(): tmp += i else: if tmp != "": L.append(tmp...
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...
s121670256
p00109
Accepted
import re class o: 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): return o(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...
s244084259
p00109
Accepted
# AOJ 0109 Smart Calculator # Python3 2018.6.18 bal4u INF = 1000000010 LEFT = INF+1 RIGHT = INF+2 PLUS = INF+3 MINUS = INF+4 MUL = INF+5 DIV = INF+6 token = { '+':PLUS, '-':MINUS, '*':MUL, '/':DIV } rank = { PLUS:2, MINUS:2, MUL:3, DIV:3, LEFT:1, RIGHT:1 } S, top = [0]*200, 0 Q, end = [0]*200, 0 def getInt(): ...
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...
s244694570
p00109
Accepted
# -*- 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 Num(self.x + value.x) def __sub__(self, value): return Num(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...
s265451778
p00109
Accepted
pos = 0 def number(s): global pos x = pos if s[pos] == '-' or s[pos] == '+': pos += 1 while s[pos].isdigit(): pos += 1 return int(s[x:pos]) expression = None def factor(s): global pos if s[pos] == '(': pos += 1 result = expression(s) pos += 1 return result else: return number(s) def term(s): glob...
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...
s894892066
p00109
Accepted
abs2 = 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...
s069393053
p00109
Accepted
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s operator = {"+":(lambda x,y: x+y), "-":(lambda x,y: x-y), "*":(lambda x,y: x*y), "/":divide } def ind(src, x): if x not in src:return 1<<30 return src.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...
s712607780
p00109
Accepted
def divide(x, y): s = 1 if(x < 0):s *= -1 if(y < 0):s *= -1 return abs(x) / abs(y) * s operator = {"+":(lambda x,y: x+y), "-":(lambda x,y: x-y), "*":(lambda x,y: x*y), "/":divide } def ind(src, x): if x not in src:return 1<<30 return src.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...
s500728205
p00109
Accepted
#!/usr/bin/env python from __future__ import division, print_function from sys import stdin, exit from operator import add, sub, mul, truediv def div(a, b): return int(truediv(a, b)) class Parser(list): """ <statement> ::= <expression> "=" <expression> ::= <term> [ ("+"|"-") <term> ] <term> ::= ...
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...
s622044773
p00109
Accepted
s = ""; l = 0; def expr(idx): ret, idx = term(idx) while idx<l: if s[idx]=='+': r, idx = term(idx+1) ret += r elif s[idx]=='-': r, idx = term(idx+1) ret -= r else: break return ret, idx def term(idx): ret, idx = fac...
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...
s320306046
p00109
Accepted
import math def calc_zyouzyo(siki) : j = 0 while True : if '*' not in siki and '/' not in siki: break if siki[j] == '*' : siki[j-1] = str(int(siki[j-1]) * int(siki[j+1])) del siki[j:j+2] elif siki[j] == '/' : if (int(siki[j-1]) < 0 and int(...
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...
s395728278
p00109
Accepted
# -*- coding: utf-8 -*- ''' 所要時間は、分位であった。 ''' # ライブラリのインポート #import re import sys input = sys.stdin.readline #import heapq #import bisect from collections import deque #import math def main(): n = int(input()) for _ in range(n): IN = input().strip() exp1 = calcmold(IN) exp2 = calc1(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...
s515176419
p00109
Accepted
import heapq from collections import deque from enum import Enum import sys import math from _heapq import heappush, heappop import copy BIG_NUM = 2000000000 MOD = 1000000007 EPS = 0.000000001 line = [] def calc_E(left,right): global line depth = 0 Q = deque() #深さ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...
s111113898
p00109
Accepted
class c: def __init__(self, v): self.value = v def __str__(self): return str(self.value) def __add__(self, other): return c(self.value + other.value) def __sub__(self, other): return c(self.value - other.value) def __mul__(self, other): return c(self.value * 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...