代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/6 """ PAT 乙级 1018 """ if __name__ == '__main__': n = int(input()) first = [0, 0, 0] second = [0, 0, 0] first_win = 0 second_win = 0 alphabet = ['B', 'C', 'J'] for _ in range(n): p1, p2 = input().split() if p1 == 'C' and p2 == 'J':...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/8 """ PAT 乙级 1022 """ if __name__ == '__main__': num1, num2, base = map(int, input().split(' ')) total = num1 + num2 if total == 0: print(0) exit(0) res = [] while total >= 1: res = [total % base] + res total = total // base if...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/3 """ PAT 乙级 1013 """ import math def is_prime(num): for i in range(2, int(math.sqrt(num)) + 1): if num % i == 0: return False return True if __name__ == '__main__': nums_str = input().split(' ') m, n = int(nums_str[0]),...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/3 """ PAT 乙级 1009 """ if __name__ == '__main__': statement = input().split(' ') statement.reverse() print(' '.join(statement))
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/3 """ PAT 乙级 1007 """ import math def is_prime(n): prime = True for i in range(3, int(math.sqrt(n)) + 1): if n % i == 0: prime = False break return prime if __name__ == '__main__': nums = [n for n in range(3, int(input()) + 1)]...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/3 """ PAT 乙级 1006 """ if __name__ == '__main__': chars = [*input()] chars.reverse() tail = [] for i in range(1, int(chars[0]) + 1): tail.append(str(i)) bs_list = [[], []] for i, char in enumerate(chars[1:]): if i == 0: bs_list[0]...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/2 """ PAT 乙级 1005 """ def compute_sequence(num): sequence = [] while num != 1: if num % 2 == 0: num = num // 2 else: num = (num * 3 + 1) // 2 sequence.append(num) return sequence if __name__ == '__main__': sequences = [] n =...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/1 """ PAT 乙级 1004 """ def get_score(student): return student[2] if __name__ == '__main__': n = int(input()) students = [] while n != 0: tokens = input().split(' ') students.append((tokens[0], tokens[1], int(tokens[2]))) n -= 1...
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/5 """ PAT 乙级 1017 """ if __name__ == '__main__': a, b = map(int, input().split(' ')) print(a // b, a % b)
代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/5 """ PAT 乙级 1016 """ def count(string, char): c = 0 for v in string: if v == char: c += 1 return c def pad(char, num): if num == 0: return '0' ret = '' while num != 0: ret += char num -= 1 return ret if __name__ == '__main__':...