Powered by:NEFU AB-IN
文章目录
3446. 整数奇偶排序
-
题意
输入 10个整数,彼此以空格分隔。
重新排序以后输出(也按空格分隔),要求:
先输出其中的奇数,并按从大到小排列;
然后输出其中的偶数,并按从小到大排列。 -
思路
模拟
-
代码
""" 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)