回分類題庫
d187: CP Lab Exercise: Hexa Calculation
出處:

Difficulity : N/A
Accepted : 44 Times | Submit :94 Times | Clicks : 1268
Accepted : 39 Users | Submit : 39 Users | Accepted rate : 100%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2010-12-01 15:11

Content :

Auror Li has found the locations of deathly hallows, however, the coordinates is not encrypted by Parseltongue; it is encrypted by hexa math formula.

As his best partner, you have to help Li to decrypt the coordinates in time in order to prevent Lord Voldemort (the one has no nose) get them.

Input :

Each line is a hexa math formula which length is less than 150.
The formula is composed by Numbers and Operators separated by spaces:

Numbers are: Positive Hex Number.   ( Composed by "0123456789ABCDEF" )

Operations are: ADD, SUB, MUL, DIV

The formula is calculated from left to right.

Each line is a valid input. (You don’t need to worry about divided by zero.)

Output :

For each set of data, output the integer calculation decimal result of the formula, that is, no float point calculation. ( 1 DIV 2 is 0 not 0.5 )

Sample Input :

1 ADD 2F MUL FE DIV 2C SUB 3
A DIV F
10 MUL 10

Sample Output :

274
0
256

Hint :

Use fgets, strtok, strtol, strcmp…etc. as tools.

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
58694. amy1 (8 ms , 416KB)
35542. sponge (8 ms , 436KB)
27431. cp99703045 (2 ms , 212KB)
27339. cp95205001 (2 ms , 220KB)
34227. king_of_laba (4 ms , 216KB)
30710. nothinglo (4 ms , 206KB)
27654. cp99703006 (4 ms , 216KB)
50785. nwgs524513cja (112 ms , 220KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡