UVA 11945 Financial Management 水题
2015-04-02 20:28
169 查看
Financial Management
Time Limit: 1 Sec Memory Limit: 256 MB题目连接
acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=20184Description
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, ( 1N
100) 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.42HINT
[b]题意[/b]啊,给你十二个月的钱,然后求平均钱数,注意在千位打逗号
[b]题解:[/b]
加起来除以12咯
[b]代码:[/b]
//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=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int buf[10]; inline void write(int i) { int p = 0;if(i == 0) p++; else while(i) {buf[p++] = i % 10;i /= 10;} for(int j = p-1; j >=0; j--) putchar('0' + buf[j]); printf("\n"); } int main() { int t=read(); for(int cas=1;cas<=t;cas++) { double sum=0; double x=0; for(int i=0;i<12;i++) { cin>>x; sum+=x; } sum/=12; int a=(int)(sum/1000); sum-=a*1000; if(a>0) printf("%d $%d,%.2f\n",cas,a,sum); else printf("%d $%.2f\n",cas,sum); } }
相关文章推荐
- uva 10252 - Common Permutation 字符串水题
- uva 110 Meta-Loopless Sorts 用程序写程序 有点复杂的回溯水题
- UVa 1225 Digit Counting --- 水题
- UVA - 488 Triangle Wave(水题)
- UVA - 10300 Ecological Premium(水题)
- uva 10891 Game of Sum (DP水题)
- UVA - 694 The Collatz Sequence(水题)
- UVALive2536 POJ1248 HDU1015 ZOJ1403 Safecracker【密码+暴力+水题】
- Uva 11729 Commando War - 水题 - 贪心
- UVA 11078 Open Credit System (水题)
- UVA-10763-交换学生-水题
- UVA - 11520 Fill the Square 水题
- UVA10310 Dog and Gopher【Ad Hoc+水题】
- UVA - 11059(暴力水题)
- Maximum Product UVA - 11059(水题)
- UVA 11995 I Can Guess the Data Structure!(水题)
- UVALive 7336 Automatic Cheater Detection【水题】
- Symmetry UVa 1595(水题)
- 思维水题:UVa512-Spreadsheet Tracking
- UVa 11059:Maximum Product(水题)