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;
}
全部评论

相关推荐

05-23 20:31
已编辑
武汉大学 Java
内向的柠檬精在研究求...:注意把武大标粗标大 本地你俩不是乱杀
实习进度记录
点赞 评论 收藏
分享
06-17 00:26
门头沟学院 Java
程序员小白条:建议换下项目,智能 AI 旅游推荐平台:https://github.com/luoye6/vue3_tourism_frontend 智能 AI 校园二手交易平台:https://github.com/luoye6/vue3_trade_frontend GPT 智能图书馆:https://github.com/luoye6/Vue_BookManageSystem 选项目要选自己能掌握的,然后最好能自己拓展的,分布式这种尽量别去写,不然你只能背八股文了,另外实习的话要多投,尤其是学历不利的情况下,多找几段实习,最好公司title大一点的
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务