当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6938:A+B Problem

题目描述
HZ has a special calculator, in which all the integers are 11-bit signed integers. The range of an 11-bit signed integer is from $-2^{10}$ to $2^{10}-1$ (from $-1024$ to $1023$). When using this calculator to calculate the sum of two integers $A$ and $B$, the result may be different from other calculators. Here are some examples:

$$
\begin{align*}
1 + 1 & = 2\\
1023 + 1 & = -1024\\
1023 + 2 & = -1023\\
-1024 + (-1) & = 1023\\
-1024 + (-2) & = 1022
\end{align*}
$$

HZ found this special calculator very strange, so he comes to you. You are given two integers $A$ and $B$, and you need to guess the result of $A+B$ of this calculator.
输入解释
The first line of input contains an integer $T$ ($1\leq T \leq 10^5$), denoting the number of test cases.

Each test case contains two integers $A$ and $B$ in one line. $-1024\leq A,B \leq 1023$.
输出解释
For each test case, print one integer in one line, denoting your answer.
输入样例
5
1 1
1023 1
1023 2
-1024 -1
-1024 -2
输出样例
2
-1024
-1023
1023
1022

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6938

最后修改于 2021-10-23T19:10:44+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)