3446. 整数奇偶排序

摘要
Title: 3446. 整数奇偶排序
Tag: 模拟
Memory Limit: 64 MB
Time Limit: 1000 ms

Powered by:NEFU AB-IN

Link

3446. 整数奇偶排序

  • 题意

    输入 10个整数,彼此以空格分隔。
    重新排序以后输出(也按空格分隔),要求:
    先输出其中的奇数,并按从大到小排列;
    然后输出其中的偶数,并按从小到大排列。

  • 思路

    模拟

  • 代码

    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
    """
    Author: NEFU AB-IN
    Date: 2023/4/18 20:30
    software: PyCharm
    File: 3446.py
    """
    # import
    import sys, math, os
    from io import BytesIO, IOBase
    from collections import Counter, deque
    from heapq import heapify, heappop, heappush, nlargest, nsmallest
    from bisect import bisect_left, bisect_right
    from datetime import datetime, timedelta
    from typing import *


    class sa:
    def __init__(self, x, y):
    self.x = x
    self.y = y

    def __lt__(self, x):
    pass


    # Final
    N = int(1e3 + 10)
    INF = int(2e9)

    # Define
    sys.setrecursionlimit(INF)
    read = lambda: map(int, input().split())

    # —————————————————————Division line ——————————————————————

    lst = list(read())

    a = list(filter(lambda x: x & 1, lst))
    b = list(filter(lambda x: x & 1 == 0, lst))

    a.sort(reverse=True)
    b.sort()

    print(*a, *b)

使用搜索:谷歌必应百度