submission_id
string
problem_id
string
status
string
code
string
input
string
output
string
problem_description
string
s575038173
p00086
Accepted
while 1: c=[0,1,1]+[0]*98 while 1: try:a,b=map(int,raw_input().split()) except:exit() if a==0==b:break c[a]=1-c[a] c[b]=1-c[b] print["NG","OK"][sum(c)==0]
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s237726739
p00086
Accepted
while 1: edges = [0] * 101 try: a, b = map(int, raw_input().split()) edges[a] += 1 edges[b] += 1 except EOFError: break while 1: a, b = map(int, raw_input().split()) if a == b == 0: break edges[a] += 1 edges[b] += 1 if edges...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s818317718
p00086
Accepted
#coding:utf-8 while 1: try: #初期化 key=[0]*101 #オイラー路:すべての頂点のうち、次数が奇数であるものがちょうど2つ(入口と出口) while 1: input = map(int, raw_input().split()) if(input[0] == 0 and input[1] == 0): break key[input[0]]+=1 key[input[1]]+=1 ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s819826400
p00086
Accepted
while True: try: lst = [] ju = True while True: a, b = map(int, input().split()) if a == 0: break lst.append(a) lst.append(b) anslst = [] for i in range(1, max(lst)+1): anslst.append(lst.count(i)) ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s079765832
p00086
Accepted
import sys readlines = sys.stdin.readlines write = sys.stdout.write def solve(): L = 100 G = [[] for i in range(L)] for line in readlines(): a, b = map(int, line.split()) if a != 0 != b: G[a-1].append(b-1) G[b-1].append(a-1) continue ok = 1 ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s480141849
p00086
Accepted
while 1: try: v = [0]*101 a, b = map(int, input().split()) v[a] += 1 v[b] += 1 while 1: a, b = map(int, input().split()) if a == 0: break v[a] += 1 v[b] += 1 flag = 0 for num in v[3:]: ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s437835554
p00086
Accepted
c = [0] * 100 while 1: try: a, b = map(int, input().split()) except: break c[a - 1] += 1 c[b - 1] += 1 if a == 0: for i in range(2, 100): if c[i] & 1: print('NG') break else: print('OK' if c[0] & 1 and c[1] & 1 e...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s157676122
p00086
Accepted
def ap(i): if len(root)<i: for _ in range(i-len(root)):root.append(0) root[i-1]=[0,1][root[i-1]==0] while 1: try: root=[0,0] while 1: n,m=map(int,input().split()) if n==m==0:break ap(n) ap(m) if root.pop(0)+root.pop(0)==2 and su...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s100576483
p00086
Accepted
cntlist = [0] * 102 while 1: try: a, b = map(int, input().split()) except: break cntlist[a] += 1 cntlist[b] += 1 if a == 0 and b == 0: for cnt in cntlist[3:]: if cnt % 2 == 1: print("NG") break else: print("OK"...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s712611823
p00086
Accepted
import sys try: while True: edges = [0]*101 while True: a, b = map(int, input().split()) if not a: break edges[a] += 1 edges[b] += 1 if edges[1]%2 == 1 and edges[2]%2 == 1 and all(n%2==0 for n in edges[3:]): print("...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s194552868
p00086
Runtime Error
import sys data = sys.stdin.readlines() targ= {} for d in data: temp = d.split(' ') if temp[0] == temp[1] == 0: for k in targ.keys(): if targ[k] % 2 != 0: print("NG") break else: print("OK") else: targ[temp] = targ.get(temp,0) +...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s379987841
p00086
Runtime Error
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0086 """ import sys from sys import stdin input = stdin.readline def main(args): while True: routes = [] while True: a, b = map(int, input().split()) if a == 0 and b == 0: ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s656794667
p00086
Runtime Error
while True: try: v=[] a,b=(int(i) for i in input().split()) while a!=0 or b!=0: while b>len(v): v.append(0) v[a]+=1 v[b]+=1 a=0 while a<len(v) and v[a]%2==0: a+=1 if a<len(v): print("NG") ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s640134573
p00086
Runtime Error
import sys v=[0]*101 for e in sys.stdin: a,b=map(int,e.split()) v[a]+=1;v[b]+=1 if a==0: print(['OK','NG'][(v[1]&1)*(v[2]&1)*sum(x&1 for x in v)-2]) v=[0]*101
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s124203302
p00086
Runtime Error
# -*- coding: utf-8 -*- # 宇都宮涼 # J5-170029 # Tax Rate Changed # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp? id=1192&lang=jp # 右中央 while True: a,b,c = map(int, input().strip().split(' ')) temp = 0 if a == 0 and b == 0 and c == 0: break for i in range(1, c): for j in range(...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s973147116
p00086
Runtime Error
# -*- coding: utf-8 -*- # 宇都宮涼 # J5-170029 # Tax Rate Changed # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp? id=1192&lang=jp # 右中央 from sys import stdin temp = [0] * 50 while True: a,b = map(int, input().strip().split(' ')) boolean = True if a == 0 and b == 0: for i in range(len(tem...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s965200829
p00086
Runtime Error
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import (division, absolute_import, print_function, unicode_literals) from sys import stdin from collections import Counter cnt = Counter() for line in stdin: start, end = (int(s) for s in line.split()) if start or end: ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s984418109
p00086
Runtime Error
while True: try: path = [0]*100 while True: a,b = map(int, raw_input().split()) if a == 0: break path[a-1] += 1; path[b-1] += 1 if (path[0]%2 == path[1]%2 == 1 ): print "OK" else: print "NG" except: break
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s302528915
p00086
Runtime Error
while True: try: path = [0]*100 while True: a,b = map(int, raw_input().split()) if a == 0: break path[a-1] += 1; path[b-1] += 1 if (path[0]%2 == 1 and path[1]%2 == 1 ): print "OK" else: print "NG" except: break
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s538059107
p00086
Runtime Error
#coding:utf-8 #初期化 key=[0]*101 flag = 0; #オイラー路:すべての頂点のうち、次数が奇数であるものがちょうど2つ(入口と出口) while 1: input = map(int, raw_input().split()) if(input[0] == 0 and input[1] == 0): break key[input[0]]+=1 key[input[1]]+=1 ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s049248997
p00086
Runtime Error
#coding:utf-8 while 1: try: #初期化 key=[0]*101 #オイラー路:すべての頂点のうち、次数が奇数であるものがちょうど2つ(入口と出口) while 1: input = map(int, raw_input().split()) if(input[0] == 0 and input[1] == 0): break key[input[0]]+=1 key[input[1]]+=1 ...
1 3 3 4 3 5 3 6 4 6 4 7 4 7 5 6 6 7 5 8 5 8 6 8 6 9 7 9 8 9 9 2 0 0 1 3 3 4 3 4 4 2 0 0
OK NG
<H1>パトロール</H1> <p> 文久2(1862)年、会津の殿様が京都守護職を命ぜられました。京都守護職とは治安の悪化した幕末の京都を守る大切な役目です。幕府や他の藩と分担して市中をパトロールしなければなりません。ところがいざ分担ルートを決める段になって、家臣の中でも有名な頑固者の古老から以下のような注文がつきました。 </p> <center> <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_14_1"> </center> <br/> <p> 大変なことになりました。殿様といえどもこの家臣の言い分を無視するわけにはいきません。分担ルー...
s520888833
p00087
Wrong Answer
while 1: try: stack = [] st = map(str, raw_input().split()) for s in st: if s == "-": stack.append(stack.pop(-2) + stack.pop()) elif s == "+": stack.append(stack.pop(-2) - stack.pop()) elif s == "/": stack.append(stack.pop(-2) * stack.pop()) elif s == "*": stack.append(stack.pop(-2) /...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s206296278
p00087
Wrong Answer
while 1: try: stack = [] st = map(str, raw_input().split()) for s in st: if s == "-": stack.append(stack.pop(-2) - stack.pop()) elif s == "+": stack.append(stack.pop(-2) + stack.pop()) elif s == "/": stack.append(stack.pop(-2) / stack.pop()) elif s == "*": stack.append(stack.pop(-2) *...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s435274068
p00087
Wrong Answer
#!/usr/bin/env python3 import sys def calc_inverse_polish_notation_string(s): tokens = [token for token in s.split(' ') if token != ''] stack = [] for token in tokens: if token in ['+', '-', '*', '/']: val2 = stack.pop() val1 = stack.pop() result = eval("%s %s ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s816512465
p00087
Wrong Answer
s=[] for p in input().split(): s+=[str(eval(s.pop(-2)+p+s.pop()))if p in"+-*"else p] print(*s)
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s914984410
p00087
Wrong Answer
s=[] for p in input().split(): s+=[str(eval(s.pop(-2)+p+s.pop()))if p in"+-*/"else p] print(*s)
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s490574048
p00087
Wrong Answer
def is_float_str(num_str, default=0): try: return {"is_float": True, "val": float(num_str)} except ValueError: return {"is_float": False, "val": default} def compute(operand, val1, val2): if operand == "+": return val1 + val2 elif operand == "-": return val1 - v...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s857277637
p00087
Wrong Answer
def is_float_str(num_str, default=0): try: return {"is_float": True, "val": float(num_str)} except ValueError: return {"is_float": False, "val": default} def compute(operand, val1, val2): if operand == "+": return val1 + val2 elif operand == "-": return val1 - val2 ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s255044209
p00087
Wrong Answer
def is_float_str(num_str, default=0): try: return {"is_float": True, "val": float(num_str)} except ValueError: return {"is_float": False, "val": default} def compute(operand, val1, val2): if operand == "+": return val1 + val2 elif operand == "-": return val1 - val2 ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s669908574
p00087
Wrong Answer
def is_float_str(num_str, default=0): try: return {"is_float": True, "val": float(num_str)} except ValueError: return {"is_float": False, "val": default} def compute(operand, val1, val2): if operand == "+": return val1 + val2 elif operand == "-": return val1 - val2 ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s054472449
p00087
Wrong Answer
def is_float_str(num_str, default=0): try: return {"is_float": True, "val": float(num_str)} except ValueError: return {"is_float": False, "val": default} def compute(operand, val1, val2): if operand == "+": return val1 + val2 elif operand == "-": return val1 - val2 ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s862130040
p00087
Wrong Answer
# AOJ 0087 Strange Mathematical Expression # Python3 2018.6.14 bal4u class Stack: def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def size(self): return len(self.items) s = Stack() while True: try: a = list(input().split()) excep...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s390250706
p00087
Wrong Answer
import sys for line in sys.stdin.readlines(): stack=[] for a in line.strip().split(): if a=="+": a=stack.pop()+stack.pop() elif a=="-": a=-(stack.pop()-stack.pop()) elif a=="*": a=stack.pop()*stack.pop() elif a=="/": a=stack.pop()/s...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s159560458
p00087
Wrong Answer
import sys for line in sys.stdin.readlines(): stack=[] for a in line.strip().split(): if a=="+": a=stack.pop()+stack.pop() elif a=="-": a=-(stack.pop()-stack.pop()) elif a=="*": a=stack.pop()*stack.pop() elif a=="/": a=stack.pop()/s...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s896020444
p00087
Wrong Answer
import sys for line in sys.stdin.readlines(): stack=[] for a in line.strip().split(): if a=="+": a=stack.pop()+stack.pop() elif a=="-": a=-(stack.pop()-stack.pop()) elif a=="*": a=stack.pop()*stack.pop() elif a=="/": a=stack.pop()/s...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s579491687
p00087
Wrong Answer
import sys for line in sys.stdin: foo=map(str, line.strip().split()) stack=[] while (foo!=[]): if foo[0]=='+': del foo[0] stack.append(int(stack.pop())+int(stack.pop())) elif foo[0]=='*': del foo[0] stack.append(int(stack.pop())*int(stack.pop())) elif foo[0]=='-': del foo[0] stack.append(-int...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s873102495
p00087
Wrong Answer
import sys for line in iter(sys.stdin.readline, ""): foo=map(str, line.strip().split()) stack=[] while (foo!=[]): if foo[0]=='+': del foo[0] stack.append(int(stack.pop())+int(stack.pop())) elif foo[0]=='*': del foo[0] stack.append(int(stack.pop())*int(stack.pop())) elif foo[0]=='-': del foo[0] ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s667037542
p00087
Wrong Answer
while True: try: inp = map(str, raw_input().split()) stuck = [] for i in inp: if i == "+": stuck.append(int(stuck.pop(len(stuck)-2)) + int(stuck.pop(len(stuck)-1)) ) elif i == "-": stuck.append(int(stuck.pop(len(stuck)-2)) - int(stuck.p...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s853244788
p00087
Wrong Answer
while True: try: inp = map(str, raw_input().split()) stuck = [] for i in inp: if i == "+": stuck.append(int(stuck.pop(len(stuck)-2)) + int(stuck.pop(len(stuck)-1)) ) elif i == "-": stuck.append(int(stuck.pop(len(stuck)-2)) - int(stuck.p...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s382343959
p00087
Time Limit Exceeded
while 1: su = 0 stack = [] try: raw = raw_input().split() except: pass else: for s in raw: if s == "-": stack.append(stack.pop(-2) - stack.pop()) elif s == "+": stack.append(stack.pop(-2) + stack.pop()) elif s == "/": stack.append(stack.pop(-2) / stack.pop()) elif s == "*": stack....
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s625892268
p00087
Time Limit Exceeded
while 1: stack = [] try: for s in raw_input().split(): if s == "-": stack.append(stack.pop(-2) - stack.pop()) elif s == "+": stack.append(stack.pop(-2) + stack.pop()) elif s == "/": stack.append(stack.pop(-2) / stack.pop()) elif s == "*": stack.append(stack.pop(-2) * stack.pop()) el...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s980011522
p00087
Time Limit Exceeded
while 1: try: stack = [] for s in raw_input().split(): if s == "-": stack.append(stack.pop(-2) - stack.pop()) elif s == "+": stack.append(stack.pop(-2) + stack.pop()) elif s == "/": stack.append(stack.pop(-2) / stack.pop()) elif s == "*": stack.append(stack.pop(-2) * stack.pop()) eli...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s176315910
p00087
Time Limit Exceeded
while 1: try: stack = [] for s in map(str, raw_input().split()): if s == "-": stack.append(stack.pop(-2) - stack.pop()) elif s == "+": stack.append(stack.pop(-2) + stack.pop()) elif s == "/": stack.append(stack.pop(-2) / stack.pop()) elif s == "*": stack.append(stack.pop(-2) * stack.pop...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s418060478
p00087
Time Limit Exceeded
while 1: try: stack = [] for s in map(str, raw_input().split()): if s == "-": stack.append(stack.pop(-2) + stack.pop()) elif s == "+": stack.append(stack.pop(-2) - stack.pop()) elif s == "/": stack.append(stack.pop(-2) * stack.pop()) elif s == "*": stack.append(stack.pop(-2) / stack.pop...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s909121233
p00087
Time Limit Exceeded
while 1: try: stack = [] st = map(str, raw_input().split()) for s in st: if s == "-": stack.append(stack.pop(-2) + stack.pop()) elif s == "+": stack.append(stack.pop(-2) - stack.pop()) elif s == "/": stack.append(stack.pop(-2) * stack.pop()) elif s == "*": stack.append(stack.pop(-2) /...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s684713568
p00087
Accepted
import sys def isNum(a) : try: int(a) except: return False return True for line in sys.stdin: stack = [] task = line.strip().split(" ") ; for i in range(0, len(task) ) : if isNum(task[i]) : stack.append(task[i]) elif len(stack) != 0 : sta...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s199357173
p00087
Accepted
while(1): try: a = [i for i in input().split()] stack = [] l = len(stack) for i in a: if i == "+": x = stack[l-2] y = stack[l-1] stack.pop() stack.pop() stack.append(x+y) elif i ==...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s778030642
p00087
Accepted
def ev( a, b, oper ): if oper == '+': return a+b if oper == '-': return a-b if oper == '*': return a*b if oper == '/': return a/b return 0 while True: try: expr = raw_input().split() except EOFError: break stack = [] for c in expr: try: stack.appe...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s628275441
p00087
Accepted
#! -*- coding: utf-8-unix -*- import sys if __name__=='__main__': lines = [x.strip() for x in sys.stdin.readlines() if x != '' and x != '\n'] for line in lines: cs = line.split() stack = [] res = 0.0 for c in cs: res = '' if not(c == '-' or c == '+' or c == '*' or c == '/'): res...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s893319073
p00087
Accepted
def solve(st): d = st.split() l = [] for i in xrange(len(d)): if d[i] == "+": l.append(l.pop()+l.pop()) elif d[i] == "-": l.append(-l.pop()+l.pop()) elif d[i] == "*": l.append(l.pop()*l.pop()) elif d[i] == "/": l.append(1/l.pop(...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s141202487
p00087
Accepted
import sys f = sys.stdin from collections import deque import operator func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv } for line in f: stack = deque() for element in line.strip().split(): if element in func: b = stack.pop() a = stack.pop() ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s944606510
p00087
Accepted
while 1: try: stack = [] for s in raw_input().split(): if s == "-": stack.append(stack.pop(-2) - stack.pop()) elif s == "+": stack.append(stack.pop(-2) + stack.pop()) elif s == "/": stack.append(stack.pop(-2) / stack.pop()) elif s == "*": stack.append(stack.pop(-2) * stack.pop()) els...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s425936581
p00087
Accepted
import sys def calc_inverse_polish_notation_string(s): tokens = [token for token in s.split(' ') if token != ''] stack = [] for token in tokens: if token in ['+', '-', '*', '/']: val2 = stack.pop() val1 = stack.pop() result = eval("%s %s %s" % (val1, token, val2...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s411096018
p00087
Accepted
def doc_string(): """ I can fly. """ while True: list = [] stack = [] if __name__ == "__main__": try: list = raw_input().split() except EOFError: break for var in list: try: stack.append(float(var)) ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s849500943
p00087
Accepted
while 1: try: l=map(str,raw_input().split()) s=[] for i in l: if i=='+': s.append(s.pop(-2)+s.pop(-1)) elif i=='-': s.append(s.pop(-2)-s.pop(-1)) elif i=='*': s.append(s.pop(-2)*s.pop(-1)) elif i=...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s209318732
p00087
Accepted
from collections import deque import operator import sys stack = deque() operators = { '+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv } for line in sys.stdin: for term in line.split(): if term in operators: a, b = stack.pop(), stack.pop() ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s732388990
p00087
Accepted
def calc(a,b,c): if c=="+": return a+b if c=="-": return a-b if c=="*": return a*b if c=="/": return a/b while(1): try: wlist=raw_input().split() stack=[] for c in wlist: if c in "+-*/": b=stack.pop() ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s641512744
p00087
Accepted
import sys def line():return sys.stdin.readline().strip() ops = {"+":lambda a,b:b + a, "-":lambda a,b:b - a, "*":lambda a,b:b * a, "/":lambda a,b:b / a} while True: try: stack = [] for s in line().split(): if s in ops: stack.append(ops[s](stack.pop(),stack...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s501863783
p00087
Accepted
import sys st=[] for a in sys.stdin: s=a.split() del st[:] for i in range(len(s)): if s[i] in ['+','-','*','/']: a=st.pop(-1) b=st.pop(-1) if s[i]=='+':c=b+a elif s[i]=='-':c=b-a elif s[i]=='*':c=b*a else: c=1.*b/a s...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s714601132
p00087
Accepted
while 1: try:s=list(input().split()) except:break a=[] for x in s: if x in ['+','-','*','/']: c,b=str(a.pop()),str(a.pop()) b+=x+c a+=[float(eval(b))] else:a+=[float(x)] print(a.pop())
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s346750712
p00087
Accepted
while 1: try:s=list(input().split()) except:break a=[] for x in s: if x in ['+','-','*','/']: c,b=str(a.pop()),str(a.pop()) a+=[float(eval(b+x+c))] else:a+=[float(x)] print(*a)
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s617361398
p00087
Accepted
def invpol(f): s = [] for c in f: if c == '+': a = s.pop() s.append(s.pop() + a) elif c == '-': a = s.pop() s.append(s.pop() - a) elif c == '*': a = s.pop() s.append(s.pop() * a) elif c == '/': a ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s444422001
p00087
Accepted
exec("try:s=list();[[[s.append(eval('{2}{1}{0}'.format(s.pop(),i,s.pop()))if(i in'+-*/')else i)for i in input().split(' ')]and print(s.pop())]for x in __import__('itertools').count()]\nexcept:pass")
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s076933477
p00087
Accepted
# -*- coding: utf-8 -*- import sys import os import math for s in sys.stdin: lst = s.split() # stack S = [] for c in lst: if c == '+': a = S.pop() b = S.pop() S.append(b + a) elif c == '-': a = S.pop() b = S.pop() ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s933789952
p00087
Accepted
import re while True: try: f = input().split() except: break stack = [] for c in f: if re.match("-*[0-9]", c) is None: b, a = str(stack.pop()), str(stack.pop()) stack.append(float(eval(a+c+b))) else: stack.append(c) print(stack[0])
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s474390133
p00087
Accepted
# -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0087 """ import sys def eval_rpn(data): result = 0 S = [] for d in data: # print('d = {}'.format(d)) if d == '+': y = S.pop() x = S.pop() S.append(x+y) elif d ==...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s044793618
p00087
Accepted
def Calculate_RPN(L): St = [] for i in L: if i == '+': b, a = float(St.pop()), float(St.pop()) St.append(a+b) elif i == '-': b, a = float(St.pop()), float(St.pop()) St.append(a-b) elif i == '*': b, a = float(St.pop()), float(St....
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s470216226
p00087
Accepted
# Aizu Problem 0087: Strange Mathematical Expression # import sys, math, os # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def upn(inputs): # inverse polish notation res = 0 stack = [] for inp in inputs: if inp in ['+', '-', '*',...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s717414768
p00087
Accepted
import sys for e in sys.stdin: a=[] for p in e.split(): if p in'+-*/':t=a.pop();a+=[str(eval(a.pop()+p+t))] else:a+=[p] print(*a)
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s471507688
p00087
Accepted
import sys for e in sys.stdin: s=[] for p in e.split(): s+=[str(eval(s.pop(-2)+p+s.pop()))if p in"+-*/"else p] print(*s)
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s530934220
p00087
Accepted
def is_float_str(num_str, default=0): try: return {"is_float": True, "val": float(num_str)} except ValueError: return {"is_float": False, "val": default} def compute(operand, val1, val2): if operand == "+": return val2 + val1 elif operand == "-": return val2 - val1 ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s309620192
p00087
Accepted
while True: try: a = input().split() stack = [] for inp in a: if inp == "+": x = stack.pop() y = stack.pop() stack.append(x+y) elif inp == "-": x = stack.pop() y = stack.pop() ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s289143731
p00087
Accepted
def get_input(): while True: try: yield ''.join(input()) except EOFError: break N = list(get_input()) for l in range(len(N)): p = N[l].split() s = [] for i in range(len(p)): if p[i] == "+": a = float(s.pop()) b = float(s.pop()) ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s372879255
p00087
Accepted
while True: try: ss = input().split() stack = [] for s in ss: if s == "+": a, b = stack.pop(), stack.pop() stack.append(b + a) elif s == "-": a, b = stack.pop(), stack.pop() stack.append(b - a) elif s == "*": a, b = stack.pop(), stack.pop() ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s005921864
p00087
Accepted
import sys for l in sys.stdin: t=l.split() l=[] for i in t: try: j=int(i) l.append(j) except: b=l.pop() a=l.pop() l.append(eval("a"+i+"b")) print("{:.6f}".format(l[0]))
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s819638844
p00087
Accepted
# AOJ 0087 Strange Mathematical Expression # Python3 2018.6.14 bal4u class Stack: def __init__(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def size(self): return len(self.items) s = Stack() while True: try: a = list(input().split()) excep...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s782276089
p00087
Accepted
import sys for line in sys.stdin.readlines(): stack=[] for a in line.strip().split(): if a=="+": a=stack.pop()+stack.pop() elif a=="-": a=-(stack.pop()-stack.pop()) elif a=="*": a=stack.pop()*stack.pop() elif a=="/": a=1.0/stack.pop...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s145255793
p00087
Accepted
import sys for s in sys.stdin.readlines(): L=[] for d in s.strip().split(): if d=="-": d=(-(L.pop()-L.pop())) elif d=="+": d=(L.pop()+L.pop()) elif d=="*": d=(L.pop()*L.pop()) elif d=="/": d=(1/L.pop()*L.pop()) L.append(floa...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s308692938
p00087
Accepted
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import (division, absolute_import, print_function, unicode_literals) from sys import stdin import re for line in stdin: stack = [] for s in line.split(): if re.match('[-+]?\d+', s): stack.append(float(s)) ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s740384722
p00087
Accepted
import sys for s in sys.stdin: stack = [] for s in s.split(): if s in ('+','-','*','/'): stack.append(eval('{2}{1}{0}'.format(stack.pop(),s,stack.pop()))) else: stack.append(float(s)) print '{:.6f}'.format(stack.pop())
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s063102092
p00087
Accepted
import sys for line in sys.stdin.readlines(): stack=[] for foo in line.strip().split(): if foo=="+": foo=stack.pop()+stack.pop() elif foo=="*": foo=stack.pop()*stack.pop() elif foo=="-": foo=-stack.pop()+stack.pop() elif foo=="/": foo=1.0/stack.pop()*stack.pop() stack.append(float(foo)) print "...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s836990301
p00087
Accepted
while True: try: inp = map(str, raw_input().split()) stuck = [] for i in inp: if i == "+": stuck.append( stuck.pop(-2) + stuck.pop(-1) ) elif i == "-": stuck.append( stuck.pop(-2) - stuck.pop(-1) ) elif i == "*": ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s845955192
p00087
Accepted
while True: try: inp = map(str, raw_input().split()) s = [] for i in inp: if i == "+": s.append( s.pop(-2) + s.pop(-1) ) elif i == "-": s.append( s.pop(-2) - s.pop(-1) ) elif i == "*": s.append( s.pop(-2) * s.pop(-1) ) elif i == "/": s.append...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s640726030
p00087
Accepted
while True: try: stack = [] for s in raw_input().split(): if s in ('+', '-', '*', '/'): stack.append(eval('{2}{1}{0}'.format(stack.pop(), s, stack.pop()))) else: stack.append(float(s)) print '%.6f' % stack.pop() except EOFError: break
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s978501368
p00087
Accepted
import sys for s in sys.stdin.readlines(): st = [] for c in s.strip().split(): if c=='+': st.append(st.pop()+st.pop()) elif c=='-': st.append(-st.pop()+st.pop()) elif c=='*': st.append(st.pop()*st.pop()) elif c=='/': st.append(1/st....
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s885956085
p00087
Accepted
import sys buf=[] op="+-*/" def f(i): b=buf.pop() a=buf.pop() if i==0:x=a+b elif i==1:x=a-b elif i==2:x=a*b else:x=a/b buf.append(x) return for s in sys.stdin: for e in s.split(): if op.count(e):f(op.index(e)) else:buf.append(float(e)) print buf.pop()
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s403308160
p00087
Accepted
import sys A=[] def f(b,a,i): if i==0:x=a+b elif i==1:x=a-b elif i==2:x=a*b else:x=a/b return x for s in sys.stdin: for e in s.split(): try:A+=[float(e)] except:A+=[f(A.pop(),A.pop(),"+-*/".index(e))] print A.pop()
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s448186763
p00087
Accepted
import sys def f(b,a,e): if e=="+":x=a+b elif e=="-":x=a-b elif e=="*":x=a*b else:x=a/b return x for s in sys.stdin: A=[] for e in s.split(): try:x=float(e) except:x=f(A.pop(),A.pop(),e) A+=[x] print A[0]
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s156276401
p00087
Accepted
d = [] while True: try: lst = list(input().split()) for i in lst: if i == '+': num = d.pop() d[-1] = d[-1] + num elif i == '-': num = d.pop() d[-1] = d[-1] - num elif i == '*': ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s916928119
p00087
Accepted
while True : try : lst = list(input().split()) except EOFError : break stack = [] for i in lst : if i == '+' : b = stack.pop(-1) a = stack.pop(-1) stack.append(a+b) elif i == '-' : b = stack.pop(-1) a = stac...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s198782350
p00087
Accepted
def RPN(states): operator = { '+': (lambda x, y: x + y), '-': (lambda x, y: x - y), '*': (lambda x, y: x * y), '/': (lambda x, y: float(x) / y) } stack = [] for z in states: if z not in operator.keys(): stack.append(int(z)) else: y ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s298021539
p00087
Accepted
try: while True: s = input().split() a = [] now = 0 for i in range(0, len(s)) : a.append(0) for i in range(0, len(s)) : if not (s[i] in ['+', '-', '*', '/']) : a[now] = int(s[i]) now += 1 else : a[now - ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s732186730
p00087
Accepted
def calc(L): stack=[] for l in L: try: l=float(l) stack.append(l) except: b=stack.pop(-1) a=stack.pop(-1) if l=="+": stack.append(a+b) elif l=="-": stack.append(a-b) elif l=="*": ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s086725392
p00087
Accepted
while True: try: L = input().split() except: break S = [] for i in L: if i not in "+-*/": S.append(int(i)) elif i == "+": S.append(S.pop()+S.pop()) elif i == "-": t = S.pop() S.append(S.pop()-t) elif i == "...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s631508251
p00087
Accepted
while 1: try: s = input().split() st = [] for v in s: if v == '+' or v == '-' or v == '*' or v == '/': a = st.pop() b = st.pop() if v == '+': st.append(a + b) elif v == '-': st...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s380296094
p00087
Accepted
def SME(N): if len(N)==1: return N else: for i in range(len(N)): if N[i] in ["*", "+", "-", "/"]: i = int(i) a, b = N.pop(i-2), N.pop(i-2) c = N.pop(i-2) N.insert(i-2, str(float(eval(a+c+b)))) return SME(...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s521615847
p00087
Accepted
def sisoku(kigou): if kigou=='+':return 0 if kigou=='-':return 1 if kigou=='*':return 2 if kigou=='/':return 3 while(1): try: line=input("").split() prnd=[int(i) if i[0]=='-' and i[1:].isdigit() or i.isdigit() else i for i in line ] ans,j=0,0 while(1): ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s810677279
p00087
Accepted
while 1: try: data = list(map(str, input().split())) except EOFError: break numlist = [] for d in data: if d == "+": val = float(numlist.pop(-2)) + float(numlist.pop(-1)) numlist.append(val) elif d == "-": val = float(numlist.pop(-2)) ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s752368484
p00087
Accepted
import re import sys for a in (l.rstrip().split() for l in sys.stdin): stack = [] for op in a: if re.match(r"(-|)[\d]+$", op): stack.append(int(op)) else: n1, n2 = stack.pop(), stack.pop() stack.append( n2 + n1 if op == "+" else...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...
s873222919
p00087
Runtime Error
import sys f = sys.stdin from collections import deque import operator func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv } for line in f: stack = deque() for element in line.strip().split(): if element.isdigit(): stack.append(int(element)) else: ...
10 2 12 - / 3 4 - 7 2 3 * + * -1 -2 3 + +
-1.000000 -13.000000 0.000000
<H1>未熟者の数式</H1> <p>博士 : ピーター君、ついにやったよ。</p> <p>ピーター : またですか。今度はどんなくだらない発明ですか。</p> <p>博士 : ついに数式を計算機で処理する画期的な方法を思いついたんだ。この表をみてごらん。 </p> <center> <table border=1> <tr><td width=200 align=center>通常の記法</td><td width=200 align=center>博士の「画期的な」記法</td></tr> <tr><td>1 + 2</td><td>1 2 +</td></tr> <tr><td>3 * 4 + 7</td><td>...