#P777. Bit++ ( 位元++ )

    ID: 777 Type: Default 500ms 64MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>BASIC800implementationn行t行Codeforces Round #173

Bit++ ( 位元++ )

題目描述

The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.

The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:

  • Operation ++ increases the value of variable x by 1.
  • Operation -- decreases the value of variable x by 1.

A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.

A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.

You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).

Bitland 的經典編程語言是 Bit++。 這種語言是如此奇特和復雜。

這種語言很奇特,因為它只有一個變量,稱為 x。 此外,還有兩個操作:

操作 ++ 將變量 x 的值增加 1。
操作 -- 將變量 x 的值減 1。
語言 Bit++ 中的語句是一個序列,由一個操作和一個變量 x 組成。 該語句不帶空格,即只能包含字符“+”、“-”、“X”。 執行一個語句意味著應用它包含的操作。

Bit++ 中的程序是一系列語句,每個語句都需要執行。 執行一個程序意味著執行它包含的所有語句。

給你一個 Bit++ 語言的程序。 x的初始值為0。執行程序並找到它的最終值(執行此程序時變量的值)。

輸入格式

The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.

Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.

第一行包含一個整數 n (1 ≤ n ≤ 150) — 程序中的語句數。

接下來的 n 行每行包含一個語句。 每個語句只包含一個操作(++ 或 --)和一個變量 x(表示為字母 «X»)。 因此,沒有空語句。 操作和變量可以按任意順序寫入。

輸出格式

Print a single integer — the final value of x.

打印一個整數 — x 的最終值。

Samples

["1\r\n++X\r\n","2\r\nX++\r\n--X\r\n"]
["1","0"]

原始資料

  • Zero1 題號:a777
  • Hydro 題號:Z0777
  • Locale:zh_TW
  • Display:open