code4sk/c/sourcecode/AlgorithmO/20230911/自增自减运算.py
2023-10-18 16:17:32 +08:00

31 lines
952 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#
'''
D. 自增自减运算
Description
小胖子正在学习汇编语言汇编语言里面有自增和自减指令叫inc和dec指令其实C语言里面也有自增和自减运算的即++和—运算,但这些指令或者运算都是有范围的,现在小胖子碰到了很长很长的整数,小胖子脑子一转,很快就想出来。现在请你也实现这个自增和自减运算。
Input
输入有多组第一行是测试数据的组数。对于每一组测试数据共有两行其中第一行是一个整数M0表示自减运算1表示自增运算第二行是一个很长的整数它的位数不超过10000位输入一定符合数学规定的要求并且不会有多余的字符。
Output
输出只有一行。
Sample Input
2
0
100
1
200
Sample Output
99
201
'''
t=int(input())
for i in range(t):
m=int(input())
a=int(input())
if m==0:
a-=1
else:
a+=1
print(a)