HDUOJ 6575 Budget

题目链接

Problem Description

Avin’s company has many ongoing projects with different budgets. His company records the budgets using numbers rounded to 3 digits after the decimal place. However, the company is updating the system and all budgets will be rounded to 2 digits after the decimal place. For example, 1.004 will be rounded down
to 1.00 while 1.995 will be rounded up to 2.00. Avin wants to know the difference of the total budget caused by the update.

Input

The first line contains an integer n (1 ≤ n ≤ 1, 000). The second line contains n decimals, and the i-th decimal ai (0 ≤ ai ≤ 1e18) represents the budget of the i -th project. All decimals are rounded to 3 digits.

Output

Print the difference rounded to 3 digits…

Sample Input

1
1.001
1
0.999
2
1.001 0.999

Sample Output

-0.001
0.001
0.000

比较容易想到的就是化成 intintint 扩大再减小来得到尾数,但是很明显数据很大,不能这么算(用 Java 大整数应该可以),所以换个思维,进不进位其实主要就看第三位,我们可以把数据当作字符串读入,直接判断最后一位即可,AC代码如下:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
char s[100];
int main(){while(~scanf("%d",&n)){double ans=0;while(n--){scanf("%s",s);int len=strlen(s);if(s[len-1]-'0'<=4) ans-=0.001*(s[len-1]-'0');else ans+=0.001*(10-(s[len-1]-'0'));}printf("%.3f\n",ans);}
}

HDUOJ 6575 Budget相关推荐

  1. HDUOJ 1114 Piggy-Bank

    HDUOJ 1114 Piggy-Bank 题目链接 Problem Description Before ACM can do anything, a budget must be prepared ...

  2. HDUOJ 1060 Leftmost Digit

    问题:求x^x的最高位 思路: 假设a = x^x,对10求对数有log(a) = x * log(x) = b.cd,其中b表示指数的最大表示,10^(.cd)就是底 具体代码参考: https:/ ...

  3. 【转】iphone - ios app maximum memory budget

    [转]iphone - ios app maximum memory budget https://stackoverflow.com/questions/5887248/ios-app-maximu ...

  4. SAP Spartacus B2B页面Budget页面的设计原理

    打开SAP Spartacus My Company菜单,第一个banner即为Budgets页面的入口: http://localhost:4200/powertools-spa/en/USD/or ...

  5. 转载 Android解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget

    当图片过大,或图片数量较多时使用BitmapFactory解码图片会出java.lang.OutOfMemoryError: bitmap size exceeds VM budget,要想正常使用则 ...

  6. android报错及解决1--Bitmap加载时,报bitmap size exceeds VM budget

    报错描述: 用Bitmap加载图片资源时,报错java.lang.OutOfMemoryError: bitmap size exceeds VM budget 原因分析: android系统限制,只 ...

  7. 完美解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget

    转自http://www.maxhis.info/androiding/bitmap-size-exceed/ 当图片过大,或图片数量较多时使用BitmapFactory解码图片会出java.lang ...

  8. 牛客 2021年度训练联盟热身训练赛第二场 E题NIH Budget

    文章目录 题目描述 输入描述: 输出描述: 示例1 题目描述 Recently, a job for an algorithms specialist opened up at NIH. You ne ...

  9. 预算分配Budget Allocation:两篇论文(二)

    1 达摩院:A Unified Framework for Marketing Budget Allocation A Unified Framework for Marketing Budget A ...

最新文章

  1. ajax+jsp自动刷新
  2. Linux eval命令
  3. hbase中为何不能向表中插入数据_Hbase快速入门(超精炼总结)
  4. oracle最大空闲时间,使用Oracle PROFILE控制会话空闲时间
  5. 可编辑选择、删除条目的ListView
  6. 在mac上安装gitlab
  7. 移动端页面字体在微信被放大,导致排版错乱
  8. 小结三种控制路由发布的方法
  9. modbus发送接收_自己编写MODBUS协议代码所踩过的坑
  10. 某车企笔试题解答(2)
  11. 微信小程序实例开发:跑起来
  12. 如何在iPhone 12上管理5G设置来保护流量和电池续航
  13. 2022-2027年中国发动机行业市场调研及未来发展趋势预测报告
  14. Okra框架(三) 搭建HTTP服务器
  15. 网站设计公司有哪些?如何找到可靠的网站设计公司?
  16. Python批量压缩图片
  17. matlab url什么意思,URL是什么 url是什么意思?
  18. 计算搭积木是否能拼接成一个整体
  19. 荟聚新动能 数创新经济 2022全国工业App和信息消费大赛在湖南株洲举行
  20. ant-design 实现 搜索功能

热门文章

  1. python基础知识7——元组
  2. caffe代码阅读8: Data_layers的实现细节(各个数据读取层的实现细节) 2016.3.25-28
  3. caffe layer层详解
  4. [句型] 二十六、特殊疑问句 3
  5. java中的依赖是啥意思_java – “ – ”(箭头)在gradle的依赖图中是什么意思?
  6. 2019年第四季度书单
  7. 分账的使用场景及解决方案
  8. WIN7 旗舰版 只有“睡眠”没有“休眠”,要怎样添加“休眠”功能?
  9. 《众妙之门——Web用户体验设计与可用性测试》一2.2 从数字上看:行为应答...
  10. do vis是什么意思_洛可小课堂 | 7.I get it和I got It的意思竟截然不同