快乐冲浪与生活

多体验、多体会、多体悟

0%

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/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', 'jou',
]


def is_earth(s: str):
    return s.isdigit()


def is_mars(s: str):
    return not is_earth(s)


def to_earth(s: str):
    tokens = s.split(' ')
    if len(tokens) == 1:
        if tokens[0] in mars_digits:
            return mars_digits.index(tokens[0])
        if tokens[0] in mars_carries:
            return (mars_carries.index(tokens[0]) + 1) * 13
    else:
        return (mars_carries.index(tokens[0]) + 1) * 13 + mars_digits.index(tokens[1])


def to_mars(s: str):
    num = int(s)
    if num < 13:
        return mars_digits[num]

    if num % 13 == 0:
        return f'{mars_carries[num // 13 - 1]}'
    else:
        return f'{mars_carries[num // 13 - 1]} {mars_digits[num % 13]}'


if __name__ == '__main__':
    n = int(input())
    lines = []
    for _ in range(n):
        line = input()
        lines.append(line)

    for line in lines:
        if is_earth(line):
            print(to_mars(line))
        else:
            print(to_earth(line))

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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':
            nums[3] += 1
        if c == 's':
            nums[4] += 1
        if c == 't':
            nums[5] += 1

    total = sum(nums)

    while total > 0:
        for i in range(6):
            if nums[i] != 0:
                print(chars[i], end='')
                nums[i] -= 1
                total -= 1

    print('')

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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

    max_num = max(stat)

    print(chr(ord('a') + stat.index(max_num)), max_num)

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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 nums:
        print(' '.join(student_dict[num]))

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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 != 0 and line[i] == 'P':
            num_pat += num_at

    print(num_pat % 1000000007)

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/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 = color_stat(line2)
    absent = 0
    for color, num in stat2.items():
        if color in stat1:
            if stat1[color] >= num:
                stat1[color] -= num
            else:
                absent += num - stat1[color]
        else:
            absent += num

    if absent == 0:
        print('Yes', sum(stat1.values()))
    else:
        print('No', absent)

今天在 git pull 时报了如下的错:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Add correct host key in /Users/a2htray/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/a2htray/.ssh/known_hosts:2
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

导致无法拉取远程仓库的代码。

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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 in scores:
            counts.append(scores[score])
        else:
            counts.append('0')
    print(' '.join(map(str, counts)))

代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/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 + gsk2[1] * 29 + gsk2[2]

    if price2 >= price1:
        flag = ''
        diff = price2 - price1
    else:
        flag = '-'
        diff = price1 - price2

    print(f'{flag}{diff // 29 // 17}.{diff // 29 % 17}.{diff % 29}')