Сравнение постов
Различия между постами
#130774 (30.12.2019 02:14)
и
#240596 (06.12.2021 05:34).
1 | def checkio(data): | |
2 | M_count = data // 1000 | |
3 | D_count = data % 1000 // 500 | |
4 | C_count = data % 1000 % 500 // 100 | |
5 | L_count = data % 1000 % 500 % 100 // 50 | |
6 | X_count = data % 1000 % 500 % 100 % 50 // 10 | |
7 | V_count = data % 1000 % 500 % 100 % 50 % 10 // 5 | |
8 | I_count = data % 1000 % 500 % 100 % 50 % 10 % 5 | |
9 | ||
10 | if I_count > 3: | |
11 | if V_count == 1: | |
12 | roman_number = 'IX' | |
13 | else: | |
14 | roman_number = 'IV' | |
15 | else: | |
16 | roman_number = 'V' * V_count + 'I' * I_count | |
17 | ||
18 | if X_count > 3: | |
19 | if L_count == 1: | |
20 | roman_number = 'XC' + roman_number | |
21 | else: | |
22 | roman_number = 'XL' + roman_number | |
23 | else: | |
24 | roman_number = 'L' * L_count + 'X' * X_count + roman_number | |
25 | ||
26 | if C_count > 3: | |
27 | if D_count == 1: | |
28 | roman_number = 'CM' + roman_number | |
29 | else: | |
30 | roman_number = 'CD' + roman_number | |
31 | else: | |
32 | roman_number = 'D' * D_count + 'C' * C_count + roman_number | |
33 | ||
34 | roman_number = 'M' * M_count + roman_number | |
35 | ||
36 | print(roman_number) | |
37 | ||
38 | ||
39 | checkio(6) |