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 1and 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

题意:给出价格,不过价格表示不太一样,如果是小数点后面是3个数字,只是数字分割符号,比如12,345 表示12345,当然是两个以下说明是小数点,求所有的价格总和,并按照题意表示方式输出
解法:
1 主要在于如何把数字转化成常规数字。我用a表示整数,b表示小数
2 前面的数字自然是整数,中间出现的数字判断是不是长度为3,后面的数字也同样判断一下,然后放入a和b内
3 再判断b是不是有进位
4 按照题目意思输出,大概就是小数是1~2位。整数位是3位,判断一下
5 代码好长。。其实重复部分很多
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main(){
string s;
cin>>s;
int len=s.length();
int i=;
while(i<len){
if(s[i]>='a'&&s[i]<='z'){
i++;
}
if(s[i]>=''&&s[i]<=''){
int f=;
long long ans=;
long long pos=;
long long num=;
while(s[i]>=''&&s[i]<=''){
pos*=;
pos+=(s[i]-'');
i++;
}
if(s[i]=='.'){
f++;
i++;
int x=;
while(s[i]>=''&&s[i]<=''){
ans*=;
ans+=(s[i]-'');
i++;
x*=;
}
if(x>=){
pos*=x;
pos+=(ans);
}else{
b+=ans;
// cout<<b<<"A"<<endl;
// cout<<"A"<<endl;
}
}
if(s[i]=='.'&&f==){
i++;
long long x=;
while(s[i]>=''&&s[i]<=''){
num*=;
num+=(s[i]-'');
i++;
x*=;
}
if(x>=){
pos*=x;
pos+=num;
}else{
b+=num;
}
}else{
i++;
}
// cout<<pos<<" "<<b<<endl;
a+=pos;
}
} a+=(b/);
b%=;
//cout<<a<<" "<<b<<endl;
string ss="";
if(a==&&b==){
cout<<"0.0"<<endl;
return ;
}
if(a==&&b){
if(b<){
cout<<"0.0"<<b<<endl;
}else{
string ls="";
while(b){
long long dns=b%;
ls+=(dns+'');
b/=;
}
reverse(ls.begin(),ls.end());
cout<<"0."<<ls<<endl;
}
return ;
}
if(a&&b==){
int los=;
while(a){
long long dns=a%;
if(los%==&&los){
ss+='.';
}
ss+=(dns+'');
a/=;
los++;
}
int ll=ss.length();
reverse(ss.begin(),ss.end());
cout<<ss<<endl;
}else{
int los=;
while(a){
long long dns=a%;
if(los%==&&los){
ss+='.';
}
ss+=(dns+'');
a/=;
los++;
}
int ll=ss.length();
reverse(ss.begin(),ss.end());
if(b<){
cout<<ss<<".0"<<b<<endl;
}else{
string ls="";
while(b){
long long dns=b%;
ls+=(dns+'');
b/=;
}
reverse(ls.begin(),ls.end());
cout<<ss<<"."<<ls<<endl;
}
}
return ;
}

Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) B的更多相关文章

  1. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) D

    The organizers of a programming contest have decided to present t-shirts to participants. There are ...

  2. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) C

    This is an interactive problem. You should use flush operation after each printed line. For example, ...

  3. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) A

    Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types ...

  4. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C

    Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...

  5. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B

    Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...

  6. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A

    Description Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the f ...

  7. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

  8. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  9. Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)

    http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...

随机推荐

  1. window上安装rabbitMQ

    win7下安装RabbitMQ http://my.oschina.net/ydsakyclguozi/blog/528835?fromerr=q7m1OxxF 前辈总结的特别详细.

  2. Codeforces Round #304 (Div. 2) C. Soldier and Cards —— 模拟题,队列

    题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果 ...

  3. ios系统的特点

    iOS优势 1). 比较稳定,因为他是一个完全封闭的系统,不开源,但是这个系统有他自己严格管理体系,比如app store的app应用:他有自己的评审规则,另外很多软件是需要收费的,这在一定程度上也说 ...

  4. hdu-5667 Sequence(矩阵快速幂+费马小定理+快速幂)

    题目链接: Sequence Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) ...

  5. Python: PS 滤镜-- 极坐标变换到平面坐标

    本文用 Python 实现 PS 中的一种滤镜 极坐标变换到平面坐标,具体的算法原理和效果可以参考之前的博客: http://blog.csdn.net/matrix_space/article/de ...

  6. Mysql数据库的打开和关闭

    Mysql数据库的打开和关闭: 选择计算机(win7)-右键管理 在新窗口选择--服务 5 找到mysql,然后右键-启动(停止)

  7. Tensorflow基础知识

    基本知识 使用 TensorFlow, 你必须明白 TensorFlow: 使用图 (graph) 来表示计算任务. 在被称之为 会话 (Session) 的上下文 (context) 中执行图. 使 ...

  8. Ubuntu install font

    最近在 Ubuntu 上使用 VLC 看视频,发现字幕有问题,中文有些是白色的框框,主要是字幕的字体不完全支持中文,但是选择字体时又没有可以使用的字体,为此整理一下 Ubuntu 如何安装字体,现在整 ...

  9. 【223】◀▶ IDL HDF 文件操作说明

    参考:I/O - HDF Routines —— HDF 操作函数 01   HDF_SD_START 打开一个 SDS 模式的 HDF 文件. 02   HDF_SD_END 关闭一个 SDS 模式 ...

  10. Hadoop 源代码组织结构

    Hadoop 2.X 包括 编译好的可以直接部署的文件hadoop-{VERSION}.tar.gz; 还有源代码文件hadoop-{VERSION}-src.tar.gz , 需要 Maven 编译 ...