Financial Management

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=20184

Description

Michael graduated of ITESO this year and finally has a job. He's making a lot of money, but somehow never seems to have enough. Michael has decided that he needs to grab hold of his financial portfolio and solve his financing problems. The first step is to figure out what's been going on with his money.

Michael has his bank account statements and wants to see how much money he has. Help Michael by writing a program to take his closing balance from each of the past twelve months and calculate his average account balance.

Input

The first line of input contains a single integer N, ( 1N100) which is the number of datasets that follow.

Each dataset consists of twelve lines. Each line will contain the closing balance of his bank account for a particular month. Each number will be positive and displayed to the penny. No dollar sign will be included.

Output

For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, a character `$', and a single number, the average (mean) of the closing balances for the twelve months. It will be rounded to the nearest penny.

Note: Used comma (,) to separate the thousands.

Sample Input

1
100.00
489.12
12454.12
1234.10
823.05
109.20
5.27
1542.25
839.18
83.99
1295.01
1.75

Sample Output

1 $1,581.42

HINT

题意

啊,给你十二个月的钱,然后求平均钱数,注意在千位打逗号

题解:

加起来除以12咯

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/* */
//**************************************************************************************
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
int buf[];
inline void write(int i) {
int p = ;if(i == ) p++;
else while(i) {buf[p++] = i % ;i /= ;}
for(int j = p-; j >=; j--) putchar('' + buf[j]);
printf("\n");
}
int main()
{
int t=read();
for(int cas=;cas<=t;cas++)
{
double sum=;
double x=;
for(int i=;i<;i++)
{
cin>>x;
sum+=x;
}
sum/=;
int a=(int)(sum/);
sum-=a*;
if(a>)
printf("%d $%d,%.2f\n",cas,a,sum);
else
printf("%d $%.2f\n",cas,sum);
}
}

UVA 11945 Financial Management 水题的更多相关文章

  1. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...

  2. UVa 1225 Digit Counting --- 水题

    UVa 1225 题目大意:把前n(n<=10000)个整数顺次写在一起,12345678910111213...,数一数0-9各出现多少字 解题思路:用一个cnt数组记录0-9这10个数字出现 ...

  3. UVa 1586 Molar mass --- 水题

    UVa 1586 题目大意:给出一种物质的分子式(不带括号),求分子量.本题中分子式只包含4种原子,分别为C.H.O.N, 原子量分别为12.01,1.008,16.00,14.01 解题思路:先实现 ...

  4. UVa 272 Tex Quotes --- 水题

    题目大意:在TeX中,左引号是 ``,右引号是 ''.输入一篇包含双引号的文章,你的任务是把他转成TeX的格式 解题思路:水题,定义一个变量标记是左引号还是右引号即可 /* UVa 272 Tex Q ...

  5. UVa 1583 Digit Generator --- 水题+打表

    UVa 1583 题目大意:如果x加上x的各个数字之和得到y,那么称x是y的生成元. 给定数字n,求它的最小生成元 解题思路:可以利用打表的方法,提前计算出以i为生成元的数,设为d,并保存在a[d]中 ...

  6. UVa 1584 Circular Sequence --- 水题

    UVa 1584 题目大意:给定一个含有n个字母的环状字符串,可从任意位置开始按顺时针读取n个字母,输出其中字典序最小的结果 解题思路:先利用模运算实现一个判定给定一个环状的串以及两个首字母位置,比较 ...

  7. UVa 10970 - Big Chocolate 水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  8. UVa 12342 Tax Calculator (水题,纳税)

    今天在uva看到一个水题,分享一下. 题意:制定纳税的总额,有几个要求,如果第一个180000,不纳,下一个300000,纳10%,再一个400000,纳15%,再一个300000,纳20%,以后的纳 ...

  9. UVA 11039 - Building designing 水题哇~

    水题一题,按绝对值排序后扫描一片数组(判断是否异号,我是直接相乘注意中间值越界)即可. 感觉是让我练习sort自定义比较函数的. #include<cstdio> #include< ...

随机推荐

  1. 【Linux】Linux基本命令扫盲【转】

    转自:http://www.cnblogs.com/lcw/p/3762927.html [VI使用] 1.在命令行模式     :在vi编辑器中将光标放在函数上,shift + k 可直接man手册 ...

  2. python 根据输入的内容输出类型

    类型判断 from functools import singledispatch import numbers from collections import abc from collection ...

  3. 3.Springboot之修改启动时的默认图案Banner

    一.SpringBoot的默认启动图案 在SpringBoot启动的时候,默认的会展示出一个spring的logo,这个图案我们用户是可以自定义的 二.自定义启动图案 方法一: Application ...

  4. 2016-2017-2 20155309南皓芯java第四周学习总结

    教材内容总结 这次我们学习的还是两章的内容,学习任务量跟上次比的话大体上来讲是差不多的. 继承与多态 继承 继承也符合DRY(Don't Repeat Yourself)原则 Role role1 = ...

  5. BFS && DFS

    HDOJ 1312 Red and Black http://acm.hdu.edu.cn/showproblem.php?pid=1312 很裸的dfs,在dfs里面写上ans++,能到几个点就调了 ...

  6. 1、树莓派3B开箱+安装系统

    说白了,树莓派就是英国人为学生开发的一款微型电脑.电脑能干什么,那就多了.英国小学生有用树莓派做气象站的,有检测家长开门回家的(可以安心玩游戏了),总之脑洞有多大就可以玩多大. 了解到了之后就一直心水 ...

  7. js处理局部scroll事件禁止外部scroll滚动解决办法,jquery.mousewheel.js处理时禁止办法说明

    js Code: <script> window.onload = function() { for (i = 0; i < 500; i++) { var x = document ...

  8. Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.

    通过LR来录制登录过程并生成脚本,设置了自动关联,并回放录制脚本,观察回放日志发现没有报error信息,说明脚本没有问题,将脚本放入Controller中设置100个用户设置运行,发现运行一段时间开始 ...

  9. 常用网络命令(windows)

      Ping命令的常用参数选项 ·ping IP –t 连续对IP地址执行Ping命令,直到被用户以Ctrl+C中断. ·ping IP -l 3000 指定Ping命令中的数据长度为3000字节,而 ...

  10. xmanager

    [root@upright91 run]# ./runBenchmark.sh updbtpcc.properties sqlTableCreates Exception in thread &quo ...