PAT1 1035 Password

题目链接
我的github

题目大意

给一些密码,要求将密码中的1(one)替换成@0(zero)替换成%l(L in lowercase)替换成LO(o in uppercase)替换成o

输入

每组包含一个测试用例,每个用例的第一行是正整数 N ≤ 1000 N\leq 1000 N1000,接着有 N N N行,每一行是一个队伍的名字和密码,名字和密码的长度都不超过10

输出

对每个用例,先在一行中输出修改的密码数 M M M,之后每行输出修改的队伍名和密码。如果没有修改的且一共只有一支队伍,就输出There is 1 account and no account is modified。如果没有修改的,但是队伍一共不止一支就输出There are N accounts and no account is modifiedN是总队伍的数量

输入样例

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa

1
team110 abcdefg332

2
team110 abcdefg222
team220 abcdefg333

输出样例

2
Team000002 RLsp%dfa
Team000001 R@spodfa

There is 1 account and no account is modified

There are 2 accounts and no account is modified

解析

字符替换就完事了

# -*- coding: utf-8 -*- 
# @Time : 2019/5/31 16:27 
# @Author : ValarMorghulis 
# @File : 1035.py
def solve():
    n = eval(input())
    res = list()
    for i in range(n):
        team, pwd = input().split()
        if '1' in pwd or '0' in pwd or 'l' in pwd or 'O' in pwd:
            if '1' in pwd:
                pwd=pwd.replace('1', '@')
            if '0' in pwd:
                pwd=pwd.replace('0', '%')
            if 'l' in pwd:
                pwd=pwd.replace('l', 'L')
            if 'O' in pwd:
                pwd=pwd.replace('O', 'o')
            res.append(team + ' ' + pwd)
    if len(res) == 0:
        if n == 1:
            print("There is 1 account and no account is modified")
        else:
            print("There are %d accounts and no account is modified" % n)
    else:
        print(len(res))
        for i in res:
            print(i)


if __name__ == "__main__":
    solve()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值