NP45. 禁止重复注册
描述
输入描述
无输出描述
Python 解法, 执行用时: 9ms, 内存消耗: 2964KB, 提交时间: 2022-07-26
# coding=utf-8 current_users = ['Niuniu','Niumei','GURR','LOLO'] new_users = ['GurR','Niu Ke Le','LoLo','Tuo Rui Chi'] for j in new_users: flag=0 for i in current_users: if i.lower()==j.lower(): print("The user name {} has already been registered! Please change it and try again!".format(j)) flag=1 break; if flag==0: print("Congratulations, the user name {} is available!".format(j))
Python 解法, 执行用时: 10ms, 内存消耗: 2836KB, 提交时间: 2022-07-11
current_users = ['Niuniu','Niumei','GURR','LOLO'] new_users = ['GurR','Niu Ke Le','LoLo','Tuo Rui Chi'] for name in new_users: if name.upper() in current_users: print('The user name {} has already been registered! Please change it and try again!'.format(name)) else: print('Congratulations, the user name {} is available!'.format(name))
Python 解法, 执行用时: 10ms, 内存消耗: 2836KB, 提交时间: 2022-06-21
current_users = ["Niuniu","Niumei","GURR","LOLO"] new_users = ['GurR','Niu Ke Le','LoLo','Tuo Rui Chi'] lower_current_users = [i.lower() for i in current_users] for user in new_users: if user.lower() in lower_current_users : print('The user name {} has already been registered! Please change it and try again!'.format(user)) else: print('Congratulations, the user name {} is available!'.format(user))
Python 解法, 执行用时: 10ms, 内存消耗: 2836KB, 提交时间: 2022-06-10
a = ["Niuniu", "Niumei", "GURR", "LOLO"] b = ["GurR", "Niu Ke Le", "LoLo", "Tuo Rui Chi"] for x in b: for y in a: if x.upper() == y.upper(): print("The user name {} has already been registered! Please change it and try again!".format(x)) break; else: print("Congratulations, the user name {} is available!".format(x))
Python 解法, 执行用时: 10ms, 内存消耗: 2840KB, 提交时间: 2022-07-16
current_users =['Niuniu','Niumei','GURR','LOLO'] new_users =['GurR','Niu Ke Le','LoLo','Tuo Rui Chi'] # new_users = [i.upper() for i in new_users] for i in new_users: if i.upper() in current_users: print('The user name %s has already been registered! Please change it and try again!'%i) else: print('Congratulations, the user name %s is available!'%i)