CF727B.Bill Total Value

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. The bill is a string in which the names of the purchases and their prices are printed in a row without any spaces. Check has the format "_name_1_price_1_name_2_price_2...name__n__price__n", where name__i (name of the i-th purchase) is a non-empty string of length not more than 10, consisting of lowercase English letters, and price__i (the price of the i-th purchase) is a non-empty string, consisting of digits and dots (decimal points). It is possible that purchases with equal names have different prices.

The price of each purchase is written in the following format. If the price is an integer number of dollars then cents are not written.

Otherwise, after the number of dollars a dot (decimal point) is written followed by cents in a two-digit format (if number of cents is between 1 and 9 inclusively, there is a leading zero).

Also, every three digits (from less significant to the most) in dollars are separated by dot (decimal point). No extra leading zeroes are allowed. The price always starts with a digit and ends with a digit.

For example:

  • "234", "1.544", "149.431.10", "0.99" and "123.05" are valid prices,
  • ".333", "3.33.11", "12.00", ".33", "0.1234" and "1.2" are not valid.

Write a program that will find the total price of all purchases in the given bill.

瓦西里刚从商店出来,现在他想重新核对账单中所有商品的总价。账单是一段字符串,其中商品名称及其价格依次排列,中间没有任何空格。账单格式为 _name_1_price_1_name_2_price_2..._name_n_price_n_,其中 _name_i_(第 i 个商品的名称)是一个非空字符串,长度不超过 10,且仅由小写英文字母组成;_price_i_(第 i 个商品的价格)是一个非空字符串,仅由数字和小数点(即十进制小数点)组成。相同名称的商品可能具有不同价格。

每个商品的价格按如下规则书写:若价格为整数美元,则不写出美分部分;否则,在美元数字后紧跟一个小数点(十进制小数点),再以两位数字格式写出美分(若美分为 1 至 9 中的某个数,则需补前导零)。

此外,美元部分的数字(从最低位向最高位方向)每三位用一个小数点(十进制小数点)分隔。不允许出现额外的前导零。价格字符串总是以数字开头,也以数字结尾。

例如:

  • "234"、"1.544"、"149.431.10"、"0.99" 和 "123.05" 是合法的价格;
  • ".333"、"3.33.11"、"12.00"、".33"、"0.1234" 和 "1.2" 是不合法的价格。

请编写一个程序,计算给定账单中所有商品的总价。

输入格式

The only line of the input contains a non-empty string s with length not greater than 1000 — the content of the bill.

It is guaranteed that the bill meets the format described above. It is guaranteed that each price in the bill is not less than one cent and not greater than 106 dollars.

输入仅有一行,包含一个非空字符串 ss,其长度不超过 1000 —— 即账单的内容。

保证该账单符合上述格式。保证账单中每个价格均不小于 1 美分,且不大于 10610^6 美元。

输出格式

Print the total price exactly in the same format as prices given in the input.

以与输入中价格完全相同的格式输出总价。

输入输出样例

  • 输入#1

    chipsy48.32televizor12.390

    输出#1

    12.438.32
  • 输入#2

    a1b2c3.38

    输出#2

    6.38
  • 输入#3

    aa0.01t0.03

    输出#3

    0.04

输入解题思路,AI测评打分。不知道怎么写?

首页