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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <unordered_map>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<ll,int>
#define Lson L, mid, ls[rt]
#define Rson mid+1, R, rs[rt]
#define sys system("pause")
const int maxn=1e5+;
using namespace std;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
inline ll read()
{
ll x=;int f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int n,m,k,t;
char a[maxn];
double ans,now,ca;
int main()
{
int i,j;
scanf("%s",a);
int len=strlen(a);
a[len]='a';
rep(i,,len)
{
if(a[i]>=''&&a[i]<='')
{
j=i;
now=,ca=;
int cnt=;
while((a[j]>=''&&a[j]<='')||a[j]=='.')j++;
while(a[j-]!='.'&&j->i)cnt++,j--;
if(cnt==&&j->i)
{
now+=0.1*(a[j]-'');
now+=0.01*(a[j+]-'');
for(k=i;k<j;k++)if(a[k]>=''&&a[k]<='')ca=ca*+a[k]-'';
}
else if(cnt==&&j->i)
{
for(k=i;k<j+;k++)if(a[k]>=''&&a[k]<='')ca=ca*+a[k]-'';
}
else
{
for(k=i;a[k]>=''&&a[k]<='';k++)ca=ca*+a[k]-'';
}
ca+=now;ans+=ca;
while(a[j]>=''&&a[j]<='')j++;
i=j;
}
}
sprintf(a,"%.2f",ans);
len=strlen(a);
for(i=;i<=len-;i++)
{
printf("%c",a[i]);
if(len--i>&&(len--i)%==)printf(".");
}
if(a[len-]>''||a[len-]>'')printf(".%c%c\n",a[len-],a[len-]);
//system("Pause");
return ;
}

Bill Total Value的更多相关文章

  1. 【21.67%】【codeforces 727B】Bill Total Value

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. Codeforce727B --- Bill Total Value(字符串处理 正则表达式)

    先说一下正则表达式 %*[a-z]表示忽略前面的小写字符,%[0-9]表示把紧接着非字符的连续数字存入t字符串中去; 从"abc123de4f"中得到"123" ...

  3. CodeForces--TechnoCup--2016.10.15--ProblemB--Bill Total Value(字符串处理)

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

  4. angularjs入门学习【应用剖析中篇】

    在上一节讲完了关于应用开发中如数据绑定,加入样式一类的基础操作后,接下来,将在应用中,与控制其有关的一些事件... 一.UI和控制器的分离 我们须要明白控制器在应用中的三个作用: [1]在应用模型中设 ...

  5. angularjs应用骨架(2)

    时隔一个星期,接着上一篇的angularjs应用骨架继续聊聊angularjs其他的其他的内容. 区分UI和控制器的职责 在应用控制器中有三种职责: 1.为应用中模型设置初始状态 2.通过$scope ...

  6. AngularJs 第三节随笔

    利用$scope暴露模型数据 利用向控制器传递$scope对象的机制,可以把模型数据暴露给试图.在你的应用中可能还有其他数据,但是只有通过$scope 触及这些数据,angular才会把它当成数据模型 ...

  7. PAT1016 × PAT1017

    本次题解是综合1016和1017两道题来讲解,原因无他,因为这两道都是模拟题,综合字符串处理.排序等考点 接手一道模拟题,一定要快速且准确地了解模拟的过程,清晰题目涉及的关键信息.比如1016要计算电 ...

  8. ZOJ 2679 Old Bill(数学)

    主题链接:problemCode=2679" target="_blank">http://acm.zju.edu.cn/onlinejudge/showProbl ...

  9. 【BZOJ1879】【SDOI2009】Bill的挑战 [状压DP]

    Bill的挑战 Time Limit: 4 Sec  Memory Limit: 64 MB[Submit][Status][Discuss] Description Input 第一行:一个整数T, ...

随机推荐

  1. 【Python@Thread】threading模块

    theading模块的Thread类 属性: name 线程名 ident 线程标识符 daemon  布尔值,标示是否为守护线程 方法: __init__(target=None, name=Non ...

  2. hdu_5904_LCIS(DP)

    题目链接:hdu_5904_LCIS 题意: 给你两串数,让你找这两串数的最长公共子序列,并且这个最长公共子序列是连续的数值 题解: 我们首先先分别处理出a,b的每个数的最长连续的长度 然后随便找一串 ...

  3. 一步一步学EF系列【4、升级篇 实体与数据库的映射】live writer真坑,第4次补发

    前言 之前的几篇文章,被推荐到首页后,又被博客园下了,原因内容太少,那我要写多点呢,还是就按照这种频率进行写呢?本身我的意图这个系列就是想已最简单最容易理解的方式进行,每篇内容也不要太多,这样初学者容 ...

  4. centos 6 安装docker

    安装 Fedora EPEL 1.yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarc ...

  5. 【入门一】一些简单的C程序及VS的安装

    实例1 用 printf 函数打印字符串 # include <stdio.h> // 预处理指令,结尾不加 ';' int main(void) // int表示该函数将返回一个整数值, ...

  6. Ubuntu14.04下手动建立快捷方式

    先在桌面创建一个文件:文件内容如下 [Desktop Entry]Encoding=UTF-8Name=eclipseComment=eclipse ideExec=/home/mars/eclips ...

  7. C - 哗啦啦村的扩建

    C - 哗啦啦村的扩建 Time Limit: 2000/1000MS (Java/Others)    Memory Limit: 512000/256000KB (Java/Others) Sub ...

  8. 【Machine Learning in Action --5】逻辑回归(LogisticRegression)

    1.概述 Logistic regression(逻辑回归)是当前业界比较常用的机器学习方法,用于估计某种事物的可能性. 在经典之作<数学之美>中也看到了它用于广告预测,也就是根据某广告被 ...

  9. sftp配置多用户权限

    sftp配置多用户权限   工作需要,用户上传文件到目录下,用ftp不太安全,选择sftp.让用户在自己的home目录下活动,不能ssh到机器进行操作.   下面开始干活. 查看ssh版本 ssh - ...

  10. Java创建对象的4种方式?

     [Java创建对象的4种方式?] 1)通过new语句实例化一个对象 2)通过反射机制创建对象 3)通过clone()方法创建一个对象  (复制) 4)通过反序列化方式创建对象