結果

問題 No.222 引き算と足し算
ユーザー yaoshimax
提出日時 2015-06-06 15:07:50
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 390 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 21:53:45
合計ジャッジ時間 1,328 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

S=raw_input()
s=1
x=0
ind=0
if(S[0]=='-'):
    s=-1
    ind+=1
elif(S[0]=='+'):
    ind+=1
while S[ind]!='-' and S[ind]!='+':
    x*=10
    x+=ord(S[ind])-ord('0')
    ind+=1
x*=s
if(S[ind]=='-'):
    s=+1
    ind+=1
elif(S[ind]=='+'):
    s=-1
    ind+=1
if(S[ind]=='-'):
    s*=-1
    ind+=1
if(S[ind]=='+'):
    ind+=1
y=0
for c in S[ind::]:
    y*=10
    y+=ord(c)-ord('0')
print x+s*y
0