湖南大学第十四届ACM程序设计新生杯(重现赛)G a+b+c+d=? (16进制与LL范围)
链接:https://ac.nowcoder.com/acm/contest/338/G
来源:牛客网
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
输入描述:
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)
输出描述:
output T lines. Each line output one integer represent the answer of a + b + c + d
输入
1
1 2 3 4
输出
10
为什么总有些水题是如此的清奇呢。。QAQ
1、16进制以0x开头,后面跟数字0~9或字母A~F(小写也可以)。如:0x2D(16进制数2D)
8进制以0开头,后面跟数字0~7。如:045(8进制数45)
如果使用printf函数输出时,可以通过格式数明符来控制输出格式。
int x=23;
printf("%x", x); // 以16进制格式输出,输出17printf("%o", x); // 以8进制格式输出,输出272、long long的范围是 -2^63 - 2^63-1
所以根据题设范围,如果四个数都是2^61,那么相加会溢出!需特判。
2^63-1表示为16进制为0x7fffffffffffffff
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
typedef long long ll;
const int mod=;
const int inf=;
const ll maxn=0x2000000000000000;
const ll maxm=0x7fffffffffffffff; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
ll a,b,c,d;
scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
if(a==maxn&&b==maxn&&c==maxn&&d==maxn)
printf("%lld8\n",maxm/);
else
printf("%lld\n",a+b+c+d);
}
return ;
}
湖南大学第十四届ACM程序设计新生杯(重现赛)G a+b+c+d=? (16进制与LL范围)的更多相关文章
- 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)
链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...
- 湖南大学第十四届ACM程序设计新生杯(重现赛)
RANK 0 题数 0 期末复习没有参加,补几道喜欢的题. A: AFei Loves Magic 签到 思路 :不需考虑 碰撞 直接计算最终状态即可. #include<bits/stdc ...
- 湖南大学第十四届ACM程序设计新生杯 E.Easy Problem
E.Easy Problem Description: Zghh likes number, but he doesn't like writing problem description. So h ...
- 湖南大学第十四届ACM程序设计新生杯 Dandan's lunch
Dandan's lunch Description: As everyone knows, there are now n people participating in the competiti ...
- 福建工程学院第十四届ACM程序设计大赛 - E - 外传:小晋逃生记
http://www.fjutacm.com/Contest.jsp?cid=705#P4 其实想清楚了就很简单,之前想了很多种方法,以为是二分什么的,看起来就像是一个单峰函数.但是发现直接暴力一波就 ...
- 福建工程学院第十四届ACM校赛M题题解 fwt进阶,手推三进制fwt
第九集,结束亦是开始 题意: 大致意思就是给你n个3进制的数字,让你计算有多少对数字的哈夫曼距离等于i(0<=i<=2^m) 思路: 这个是一个防ak题,做法是要手推公式的fwt 大概就这 ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2
题目描述 Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it fou ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)A - Array
题目描述 Given an array A with length n a[1],a[2],...,a[n] where a[i] (1<=i<=n) is positive integ ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)L - Liao Han
题目描述 Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e1 ...
随机推荐
- 【MongoDB】用Docker安装一个MongoDB最新版玩玩
1 安装 本文假设大家已经安装好了docker并能正常使用,所以不讲解如何安装docker了.用docker安装MongoDB最新版本如下: # 从repository查找mongo的相关镜像,结果很 ...
- 在linux系统下进行pip升级注意事项
今天鼓捣爬虫的时候需要用pip安装beautifulsoup4,但是出现了错误,说我的pip版本太低,需要升级一下.刚开始我用了下面这段代码: pip install --upgrade pip 显示 ...
- vscode在终端运行脚本时出现“因为在此系统上禁止运行脚本”
首先关闭vscode,再以管理员的身份运行vscode,然后打开终端执行: get-ExecutionPolicy,显示的是Restricted,表示状态是禁止的; 再执行:set-Execution ...
- 【Luogu P3834】可持久化线段树(主席树)
Luogu P3834 可持久化数据结构就是支持在历史版本上进行查询和修改操作的数据结构. 主席树就是对线段树的改进,使之可持久化. 前置知识:动态开点线段树 我们利用权值(值域)线段树统计区间内的数 ...
- 2019 ICPC Asia Nanjing Regional K. Triangle
题目:在直角坐标系中给定 p1,p2,p3构成三角形,给定p4可能在三角形边上也可能不在, 问能不能在三角形上找出p5,使得线段p4p5,平分三角形(p4必须在三角形上).不能则输出-1. 思路:四个 ...
- .NET Core应用框架AA介绍(二)
AA的开源地址 https://github.com/ChengLab/AAFrameWork AA框架是一个基础应用框架,是建立在众多大家熟知的流行工具之上并与之集成.比如:ASP.NET Core ...
- polygon()函数
polygon():draw the polygons where vertices are given in x and y. polygon(x,y=NULL,density=NULL,angle ...
- php 7.4 的 Unpacking inside arrays (...)
总的说明 php 7.4 增加了一个很有意思的功能 这是官方说明: Unpacking inside arrays <?php$parts = ['apple', 'pear'];$fruits ...
- DS1302时钟芯片驱动程序
/***************************************************************************** FileName : DS1302.c F ...
- 监控软件之open-falcon安装、配置篇
2019-07-10 一.open-falcon简介 open-falcon是由小米运维团队,从互联网公司角度为出发点,开发出来的一套面向互联网行业的企业级的开源监控系统,截至2019年7月,open ...