Bill Total Value

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 "name1price1name2price2...namenpricen", where namei (name of the i-th purchase) is a non-empty string of length not more than 10, consisting of lowercase English letters, and pricei (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.

Input

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.

Output

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

Examples
Input
chipsy48.32televizor12.390
Output
12.438.32
Input
a1b2c3.38
Output
6.38
Input
aa0.01t0.03
Output
0.04

这个题的难点在于字符串的处理,在翻看公开的代码时,我看到了一个写的特别棒的代码,充分运用了各种字符串有关的函数,感觉受益匪浅

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; } int main() {
string s;
while(cin >> s) { for(char &c : s) if(isalpha(c)) c = ' '; stringstream ss(s);
string w;
ll sum = ;
while(ss >> w) {
if(!(w.size() >= && w[w.size() - ] == '.'))
w += ".00";
ll p = ;
for(char c : w) if(isdigit(c))
p = p * + (c - ''); //牛逼
sum += p;
} char buf[];
vector<string> v;
if(sum % != ) {
sprintf(buf, "%02d", (int)(sum % ));
v.push_back(buf);
}
sum /= ;
while(sum >= ) {
sprintf(buf, "%03d", (int)(sum % ));
v.push_back(buf);
sum /= ;
}
v.push_back(to_string(sum)); //to_string() 函数将其他数据类型转化为string/***/http://www.cplusplus.com/reference/string/to_string/ reverse(v.begin(), v.end()); int i = ;
for(string s : v) {
if(i ++ != ) putchar('.');
printf("%s", s.c_str());
}
puts("");
}
return ;
}

CodeForces--TechnoCup--2016.10.15--ProblemB--Bill Total Value(字符串处理)的更多相关文章

  1. My latest news (--2016.10)

    2016.10.31 22:44 一个“程序”,打代码占40%.思考占60% 2016.10.30 20:53 周末,话说今天有晚上讲座,还点名,了,悲催.之前学习的Qt有点问题,悲催.推荐个博文:h ...

  2. Bill Total Value

    Bill Total Value time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  3. Datatables插件1.10.15版本服务器处理模式ajax获取分页数据实例解析

    一.问题描述 前端需要使用表格来展示数据,找了一些插件,最后确定使用dataTables组件来做. 后端的分页接口已经写好了,不能修改.接口需要传入页码(pageNumber)和页面显示数据条数(pa ...

  4. Codeforces Beta Round #10 B. Cinema Cashier 暴力

    B. Cinema Cashier 题目连接: http://www.codeforces.com/contest/10/problem/B Description All cinema halls ...

  5. Codeforces Beta Round #10 A. Power Consumption Calculation 水题

    A. Power Consumption Calculation 题目连接: http://www.codeforces.com/contest/10/problem/A Description To ...

  6. 2016 10 28考试 dp 乱搞 树状数组

    2016 10 28 考试 时间 7:50 AM to 11:15 AM 下载链接: 试题 考试包 这次考试对自己的表现非常不满意!! T1看出来是dp题目,但是在考试过程中并没有推出转移方程,考虑了 ...

  7. 2016.8.15上午纪中初中部NOIP普及组比赛

    2016.8.15上午纪中初中部NOIP普及组比赛 链接:https://jzoj.net/junior/#contest/home/1333 这次比赛不怎么好,因为这套题目我并不是很擅长. 可同学们 ...

  8. 2016.10.4初中部下午NOIP普及组比赛总结

    2016.10.4初中部下午NOIP普及组比赛总结 这次的题有些水,只是第四题有点坑. 题目: 比赛:AC+0+AC+50=250 改题:AC+AC+AC+50=350 一.Bill 满地都是水 题目 ...

  9. 背水一战 Windows 10 (15) - 动画: 缓动动画

    [源码下载] 背水一战 Windows 10 (15) - 动画: 缓动动画 作者:webabcd 介绍背水一战 Windows 10 之 动画 缓动动画 - easing 示例演示缓动(easing ...

  10. Linux Kernel 3.11.4/3.10.15/3.4.65/3.0.99

    Linux 今天又发布了4个更新版本,分别是: 3.11.4 2013-10-05 [tar.xz] [pgp] [patch] [view patch] [view inc] [cgit] [cha ...

随机推荐

  1. CodeForces 605A Sorting Railway Cars 思维

    早起一水…… 题意看着和蓝桥杯B组的大题第二道貌似一个意思…… 不过还是有亮瞎双眼的超短代码…… 总的意思呢…… 就是最长增长子序列且增长差距为1的的…… 然后n-最大长度…… 这都怎么想的…… 希望 ...

  2. Scala Tuple类型

    Tuple可以作为集合存储不同类型的数据,初始化实例如下: val tuple = (1,3,3.14,"aa") val third = tuple._3 Tuple 下标访问从 ...

  3. Wsyscheck(系统检测维护工具) v1.68.33绿色版

    软件名称:系统检测维护工具(Wsyscheck) v1.68.33绿色版软件类别:国产软件运行环境:windows软件语言:简体中文授权方式:免费版软件大小:1022 KB软件等级:整理时间:2011 ...

  4. Announcement

    本来是习惯把每天的内容写在一个txt里. 似乎不符合要求.无论格式还是内容.于是转战blog. 事实上.有专业课学习加上马上考四级以及下学期可能的专业调整.此学期时间紧张. 能完成日常作业并掌握周课内 ...

  5. windows7旗舰版系统自带组件IIS搭建ftp

    1.win7,”开始“,打开”控制面板“,点击”程序“,看到”程序和功能“,如图所示: 2.点击”打开或关闭Windows功能“,如图所示: 3.成功后,打开”控制面板“,点击”系统和安全“,点击”管 ...

  6. 查看Android下生成的.db数据库

    1.在cmd中找到sdk中的platform-tools文件夹. 2.输入adb shell命令. 3.再输入sqlite3 /data/data/com.svs.db/databases/svs.d ...

  7. 解决网页在手机浏览器打开不停刷新的方案(百度的ua自动转向js问题)

    一:发现问题 原有可能是网站内挂了一个百度的ua自动转向js,手机访问的话会被自动转到feiyujd.com,然后又被转到www点feiyujd点com,这样反复死循环.就形成了一直在刷新,网站一闪一 ...

  8. javaScript中的一些知识

    利用js动态生成table <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http ...

  9. 超界文字滚动 (id和类型两种实现方式)

    //根据元素id <!DOCTYPE html><html lang="zh-CN"><head> <meta charset=" ...

  10. 几个可用于数据挖掘和统计分析的java库

    http://itindex.net/blog/2015/01/09/1420751820000.html WEKA:WEKA是一个可用于数据挖掘任务的机器学习算法集合.该算法可以直接应用到数据集或从 ...