import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
n = int(input())
print(1000-n-n)
import math
import sys
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
# n = int(input())
n = input()
this = str()
for i in n:
if int(i)%2==0:
this += "#"
else:
this += "*"
print(this)
或者下面这种方法:用位运算来,在底层上来看更快,只需要一个CPU指令就可以完成
作者:(i.dk)
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
n = input()
l = ''
for x in n:
if int(x)&1: l += '*'
else: l+= '#'
print(l)
注:奇数最后一位是1,偶数是0,由于权都是2的次幂,但是前面的0或者1都是可以被2整除,而最低位是
2
0
2^0
20,相当于偶数的基础上+1,变为奇数
同时注意这里是对1(001)进行与的,相当于对这个数的最低位判断是否为1,按位与为1,则表示来的数最低位是1,表示奇数,给*
或者上述第一种更加优雅的写法(作者:Lyden)
n = input()
o = ['*' if int(i)%2 else '#' for i in n]
print(''.join(o))
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
_str = input()
output = ''
for char in _str:
if char.islower():
output += char.upper()
else:
output += char.lower()
print(output)
或者直接调用函数
作者:Medara
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
_str = input()
# Write an answer using print
# To debug: print("Debug messages...", file=sys.stderr, flush=True)
# 大小写字母互换的函数
print(_str.swapcase())