酷代码 AI
菜单
全部AI  /  热门  /  AI写代码神器
服务商

7-30 数字比较游戏 分数 200 作者 zhang jiu jie 单位 包头师范学院 小磊和小萌是好朋友,他们非常喜欢用编程来处理问题。这次,他么要进行数字的比较问题:他们分别有一个正整数,他们要比的是,谁的正整数里面含有的数字符号种类更多。 输入格式: 输入两个正整数n和m,分别代表小磊和小萌的正整数,以空格分隔。 1 <= n、m <= 1000000000 输出格式: 请在这里描述输出格式。例如:对每一组输入,在一行中输出a+b的值。 输入样例: 如果小磊的正整数里面含有的数字符号种类更多,输出congratulations, xiaolei. 如果小萌的正整数里面含有的数字符号种类更多,输出congratulations, xiaomeng. 如果一样多,则输出we both win. 333 123 输出样例: 在这里给出相应的输出。例如: congratulations, xiaomeng. 代码长度限制 16 kb 时间限制 400 ms 内存限制 64 mb 栈限制 8192 kb

```python def count_digit_types(num): digit_set = set() while num > 0: digit = num % 10 digit_set.add(digit) num //= 10 return len(digit_set) n, m = map(int, input().split()) n_digit_types = count_digit_types(n) m_digit_types = count_digit_types(m) if n_digit_types > m_digit_types: print("congratulations, xiaolei.") elif n_digit_types < m_digit_types: print("congratulations, xiaomeng.") else: print("we both win.") ``` [2024-10-18 11:41:44 | AI写代码神器 | 158点数解答]

相关提问