题意:给定12个数,求平均数。

析:这个题就是精度控制问题,如果控制精度,最好的办法就是用整型了。

代码如下:

#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
using namespace std ;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 2e5 + 5;
const int dr[] = {0, 0, -1, 1};
const int dc[] = {-1, 1, 0, 0};
int n, m;
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[maxn]; int main(){
int T; cin >> T;
while(T--){
double sum = 0;
double x;
for(int i = 0; i < 12; ++i){
cin >> x;
sum += x;
}
int ans = (int)round(sum * 100.0/12.0);
printf("$");
printf("%d", ans/100);
int y = ans % 100;
if(!y);
else{
printf(".%d", y /10);
y = y % 10;
if(!y) ;
else printf("%d", y %10);
}
printf("\n");
}
return 0;
}

HDU 4493 Tutor (控制精度)的更多相关文章

  1. hdu 4493 Tutor 水题

    Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...

  2. HDU 4493 Tutor 水题的收获。。

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...

  3. hdu 4493 Tutor

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4493 给你十二个月的工资,算平均数,保留两位,去除末尾的0 使用暴力解决,嘻嘻,但是这题主要是在进位这个地 ...

  4. HDU 4493 Tutor (水题)

    Tutor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submi ...

  5. HDU 4493 Tutor(精度处理)

    题目 #include<stdio.h> int main() { int t; double a,s; scanf("%d",&t); while(t--) ...

  6. Hdu 4493

    题目链接 注意四舍五入,保留到小数点后两位(如果存在的话). 附上代码: /************************************************************** ...

  7. poj 1064 (二分+控制精度) && hdu 1551

    链接:http://poj.org/problem?id=1064 Cable master Time Limit: 1000MS   Memory Limit: 10000K Total Submi ...

  8. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  9. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

随机推荐

  1. (转) error: linker command failed with exit code 1 (use -v to see invocation)

    转自:http://blog.csdn.net/tiantian1980/article/details/9175777   像这样的一大堆,总体说编译链接时错误 /Users/zhangtianji ...

  2. mysql-备份和还原(普通还原和binlog还原)

    1)备份 mysqldump -uroot -proot share -l -F > /tmp/share.sql 说明:-l 锁表 -F 刷新日志文件(相当于flush logs) 2)还原( ...

  3. spring.net IOC容器

    spring.net 通过配置文件的方式 帮我们实现了IoC功能,实现方式非常灵活,且多种多样. 点击查看 创建对象 我们只需定义接口和实现方法,spring.net帮我们实现了其他功能. 第一步,定 ...

  4. 关于"user.dir"的认识

    最近阅读了一些tomcat源码,看到tomcat在读取jar包外配置文件,是将“user.dir”的路径作为home path文件即 通过System.getProperty("user.d ...

  5. openssl安装

    www.openssl.orgconfigure the environment:<pre lang="bash" escaped="true">t ...

  6. Wiz发布cnblog笔记

    [转自Wiz官网][插件]发布笔记到博客,更好的博客离线撰写工具 发表于 2011 年 2 月 23 日 由 admin 为知笔记支持绝大部分的博客离线撰写,可以方便地把笔记直接发布为博客. 使用 打 ...

  7. 剖析OkHttp缓存机制

    现在应用市场上的 App 无一不需要网络操作,这些应用的开发者大多数都选择结合使用 OkHttp 和 Retrofit 来完成网络操作.okHttp 最为人称道的一个特性就是它的缓存机制,而我将在本篇 ...

  8. 树莓派 不稳定 ssh经常断 解决

    确保供电没问题,供电至少要0.7A,如果USB口有接东西就要更多 几个提高树莓派网络稳定性的方法 TroubleShooting(推荐!好多问题的解决方案) 设置树莓派SSH连接因超时闲置断开 树莓派 ...

  9. [再寄小读者之数学篇](2014-11-19 $\sin(x+y)=\sin x\cos y+\cos x\sin y$)

    $$\bex \sin(x+y)=\sin x\cos y+\cos x\sin y. \eex$$ Ref. [Proof Without Words: Sine Sum Identity, The ...

  10. 插件二之页面加载进度条pace.js

    关于pace.js pace.js包含14样式,每种样式可以自定义颜色,官方下载中提供了几种颜色的主题,使用方式也很简单,引入pace的js文件跟所需样式文件即可 <link rel=" ...