HDU 4493 Tutor (控制精度)
题意:给定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 (控制精度)的更多相关文章
- hdu 4493 Tutor 水题
Tutor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...
- HDU 4493 Tutor 水题的收获。。
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...
- hdu 4493 Tutor
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4493 给你十二个月的工资,算平均数,保留两位,去除末尾的0 使用暴力解决,嘻嘻,但是这题主要是在进位这个地 ...
- HDU 4493 Tutor (水题)
Tutor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submi ...
- HDU 4493 Tutor(精度处理)
题目 #include<stdio.h> int main() { int t; double a,s; scanf("%d",&t); while(t--) ...
- Hdu 4493
题目链接 注意四舍五入,保留到小数点后两位(如果存在的话). 附上代码: /************************************************************** ...
- poj 1064 (二分+控制精度) && hdu 1551
链接:http://poj.org/problem?id=1064 Cable master Time Limit: 1000MS Memory Limit: 10000K Total Submi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
随机推荐
- Servlet生命周期以及获取参数
1. 创建Servlet几种方式 1) 实现Servlet接口 控制Servlet的生命周期 构造器 init() service() des ...
- LeetCode Longest Common Prefix 最长公共前缀
题意:给多个字符串,返回这些字符串的最长公共前缀. 思路:直接逐个统计同一个位置上的字符有多少种,如果只有1种,那么就是该位是相同的,进入下一位比较.否则终止比较,返回前缀.可能有一个字符串会比较短, ...
- ecshop文章详情页显示浏览数
1.后台执行以下SQL语句 ) NOT NULL 2.找到article.php的这段代码 else { $smarty->display('article_pro.dwt', $cache_i ...
- reverse(), extend(), sort() methods of list
>>> l = list('sdf') >>> l ['s', 'd', 'f'] >>> id(l) 4520422000 >>&g ...
- HDU 3078 Network
简单的 RMQ: 先预处理得到 所有 节点的 公共祖先 和 dfs 得到所有节点的父亲节点: 然后 询问时,从自己出发向上找父亲, 然后 得到所有的节点:排序一下 不知道 这题这样也 ...
- aspose.word 查找文本并加下划线
private Run SplitRun(Run run, int position) { Run beforeRun = (Run)run.Clone(true); beforeRun.Text = ...
- android 横竖屏限制如何配置
在开发android的应用中,有时候需要限制横竖屏切换.只需要在AndroidManifest.xml文件中加入android:screenOrientation属性限制. ndroid:screen ...
- 服务器中判断客户端socket断开连接的方法
1, 如果服务端的Socket比客户端的Socket先关闭,会导致客户端出现TIME_WAIT状态,占用系统资源. 所以,必须等客户端先关闭Socket后,服务器端再关闭Socket才能避免TIME_ ...
- POJ 2241 Mondriaan's Dream
题意:给一块n×m的空地,用1×2的砖铺,有多少种方案. 解法:状压dp.考虑dp[i][j]表示前i - 1行都铺满时第i行的状态为j时的方案数.对于第i行,每个格子上是否有砖用0和1表示,0表示不 ...
- C#中实现对Excel特定文本的搜索
打开Excel的VBA帮助,查看Excel的对象模型,很容易找到完成这个功能需要的几个集合和对象: Application.Workbooks. Workbook.Worksheets还有Worksh ...