电子保险箱(3 位密码)可行数量
Safe Cracking
题目详情
某电子保险箱密码为 3 位数字(000–999)。已知:
- 密码不是奇数(即末位为偶数);
- 密码不包含数字 6;
- 三位中至少有一位数字出现不止一次(存在重复)。
问:满足这三个条件的密码共有多少个?
An electronic safe has a three digit passcode. You are given three constraints regarding the code. Firstly, the code is not an odd number. Secondly, the code does not contain the number six. Lastly, one of the digits appears more than once. How many possible three digit entries satisfy these three requirements?
解析
可用数字集合为 (9 个)。末位需为偶数,且不能是 6,因此末位可选 (4 个)。
先算满足前两条的总数:
再减去三位互不相同(无重复)的数量:末位先选 4 种;第一位从剩余 8 种里选;第二位从剩余 7 种里选:
因此至少有重复的数量为
(此解默认允许前导零,符合“3 位密码”常见设定。)