代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/26 """ PAT 乙级 1046 """ if __name__ == '__main__': n = int(input()) a = 0 b = 0 for i in range(n): tokens = list(map(int, input().split(' '))) if tokens[1] == tokens[3]: continue total = tokens[0] + tokens[2] if tokens[1] == total:...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/25 """ PAT 乙级 1044 """ mars_digits = [ 'tret', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jly', 'aug', 'sep', 'oct', 'nov', 'dec', ] mars_carries = [ 'tam', 'hel', 'maa', 'huh', 'tou', 'kes', 'hei', 'elo', 'syy', 'lok', 'mer',...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/25 """ PAT 乙级 1043 """ if __name__ == '__main__': line = input() nums = [0] * 6 chars = ['P', 'A', 'T', 'e', 's', 't'] for c in line: if c == 'P': nums[0] += 1 if c == 'A': nums[1] += 1 if c == 'T': nums[2] += 1 if c == 'e':...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/25 """ PAT 乙级 1042 """ if __name__ == '__main__': line = input() stat = [0] * 26 for c in line: if ord('a') <= ord(c) <= ord('z'): stat[ord(c) - ord('a')] += 1 if ord('A') <= ord(c) <= ord('Z'): stat[ord(c) - ord('A')] += 1...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/25 """ PAT 乙级 1041 """ if __name__ == '__main__': n = int(input()) student_dict = {} for _ in range(n): tokens = input().split(' ') student_dict[tokens[1]] = [tokens[0], tokens[2]] _ = input() nums = input().split(' ') for num in...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/25 """ PAT 乙级 1039 """ if __name__ == '__main__': line = input() num_t = 0 num_at = 0 num_pat = 0 for i in range(len(line) - 1, -1, -1): if line[i] == 'T': num_t += 1 if num_t != 0 and line[i] == 'A': num_at += num_t if num_at !=...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/25 """ PAT 乙级 1039 """ def color_stat(s): stat = {} for c in s: if c not in stat: stat[c] = 0 stat[c] = stat[c] + 1 return stat if __name__ == '__main__': line1 = input() line2 = input() stat1 = color_stat(line1) stat2 =...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/13 """ PAT 乙级 1038 """ if __name__ == '__main__': n = int(input()) scores = {} for score in input().split(' '): if score not in scores: scores[score] = 0 scores[score] += 1 counts = [] for score in input().split(' ')[1:]: if score...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/13 """ PAT 乙级 1037 """ def get_gsk(s): return list(map(int, s.split('.'))) if __name__ == '__main__': gsk1, gsk2 = map(get_gsk, input().split(' ')) price1 = gsk1[0] * 17 * 29 + gsk1[1] * 29 + gsk1[2] price2 = gsk2[0] * 17 * 29 +...

代码 #!/usr/bin/env python # -*- coding: utf-8 -*- # author: a2htray # create date: 2023/3/13 """ PAT 乙级 1036 """ if __name__ == '__main__': tokens = input().split(' ') n = int(tokens[0]) c = tokens[1] row_num = str(1.0 * n / 2) if '.' in row_num: num, fraction = row_num.split('.') if 5 <= int(fraction[0]) <= 9: num =...