This is a very simple problem! Your only job is to calculate a + b + c + d!

题目链接:https://ac.nowcoder.com/acm/contest/338/G
原文链接:https://blog.csdn.net/ordinarv/article/details/85932520

There are several cases.
In the first line, there is a single integer T.(T <= 200)
In the next T lines, each line contains four integers a, b, c and d(-2 ^ 61 <= a,b,c,d <=2 ^ 61)
2 ^ 61设坑精良,long long(8字节 * 每字节8位 - 1个符号位)到 2 ^ 63,假设a、b、c、d每个都是2 ^ 61,两个相加就是 2 ^ 62,三个相加就是 2 ^ 63,四个相加就是 2 ^ 64…long long溢出…然后就得用long double(12字节)

%.0f 会四舍五入,貌似根据.后第一位是否大于4判断。

floor函数 向下取整,即取不大于x的最大整数(与“四舍五入”不同,下取整是直接取按照数轴上最接近要求值的左边值,即不大于要求值的最大的那个值)。

long double 是用 %Lf 输出!

#include<bits/stdc++.h>
using namespace std;

long double a, b, c, d;
int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        scanf("%Lf%Lf%Lf%Lf", &a, &b, &c, &d);
        printf("%.0Lf\n", floor(a + b + c + d));
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值