結果

問題 No.49 算数の宿題
ユーザー damindamin
提出日時 2020-11-04 04:22:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 570 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 8,136 KB
最終ジャッジ日時 2023-08-24 17:48:48
合計ジャッジ時間 915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,932 KB
testcase_01 AC 17 ms
8,116 KB
testcase_02 AC 16 ms
7,984 KB
testcase_03 AC 16 ms
7,940 KB
testcase_04 AC 16 ms
7,940 KB
testcase_05 AC 15 ms
7,960 KB
testcase_06 AC 15 ms
8,004 KB
testcase_07 AC 16 ms
7,960 KB
testcase_08 AC 15 ms
7,876 KB
testcase_09 AC 15 ms
8,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
try:
    import os
    f = open('input.txt', 'r')
    sys.stdin = f
except FileNotFoundError:
    None
from math import sqrt, ceil
input=lambda: sys.stdin.readline().strip()

def expr():
    global now
    x = num()
    while now<n and s[now] in "*+":
        op=s[now] ;now+=1
        y =num()
        if op =="*":
            x+=y
        else:
            x*=y
    return x

def num():
    global now
    ans=0
    while now<n and s[now].isdecimal():
        ans= ans*10 + int(s[now])
        now+=1
    return ans


s=input()
n=len(s)
now=0
print(expr())
0