結果
| 問題 |
No.708 (+ー)の式
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2018-07-16 18:11:48 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 485 bytes |
| コンパイル時間 | 3,619 ms |
| コンパイル使用メモリ | 66,336 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 03:12:08 |
| 合計ジャッジ時間 | 3,781 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport]
ソースコード
import strutils, sequtils, algorithm
var
s=stdin.readLine
res=0
i=s.len-1
while i>=0:
if s[i]==')' or s[i].isDigit:
var sub=0
if s[i]==')':
i-=1
while s[i]!='(':
if s[i].isDigit:
var sgn=if i-1>=0 and s[i-1]=='-': -1 else : 1
sub+=(s[i].ord-'0'.ord)*sgn
i-=1
elif s[i].isDigit:
sub=s[i].ord-'0'.ord
# s[i]='(' or Digit
var sgn=if i-1>=0 and s[i-1]=='-': -1 else : 1
res+=sub*sgn
i-=1
echo res
ikd