L1-027 出租 (20 分)
摘要
Title: L1-027 出租 (20 分)
Tag: 格式化输出大括号
Memory Limit: 64 MB
Time Limit: 1000 ms
Powered by:NEFU AB-IN
L1-027 出租 (20 分)
-
题意
见原题
-
思路
想在f格式化串中输出,则需要两个进行嵌套
当然也可以用%这种方法进行代替 -
代码
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'''
Author: NEFU AB-IN
Date: 2022-04-15 16:06:03
FilePath: \ACM\GPLT\L1-027.PY
LastEditTime: 2022-04-15 16:29:13
'''
from copy import deepcopy
from collections import Counter
s = list(map(int, input()))
ss = deepcopy(s)
ss = sorted(list(set(s)), reverse=True)
d = Counter()
for i in range(len(ss)):
d[ss[i]] = i
ans = []
for i in range(len(s)):
ans.append(d[s[i]])
print(f"int[] arr = new int[]{{{','.join(map(str, ss))}}};")
print(f"int[] index = new int[]{{{','.join(map(str, ans))}}};")
# print("int[] arr = new int[]{%s};" % (",".join(map(str, ss))))
# print("int[] index = new int[]{%s};" % (",".join(map(str, ans))))