-
Notifications
You must be signed in to change notification settings - Fork 0
/
#백준 단계별로 풀어보기6.py
162 lines (132 loc) · 3.11 KB
/
#백준 단계별로 풀어보기6.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#백준 단계별로 풀어보기6
# 3003번
n_list = list(map(int,input().split()))
c = [1,1,2,2,2,8]
result = []
for i in range(len(n_list)):
tem = c[i] - n_list[i]
result.append(tem)
res = ' '.join(str(s) for s in result)
print(res)
# 2444번
n = int(input())
# 다이아몬드를 저장할 리스트 초기화
diamond = [" " * (2 * n - 1) for _ in range(2 * n - 1)]
# 다이아몬드 만들기
for i in range(n):
diamond[i] = " " * (n - 1 - i) + "*" * (2 * i + 1)
diamond[2 * n - 2 - i] = diamond[i]
# 다이아몬드 출력
for row in diamond:
print(row)
# 10812번
n , m = map(int,input().split())
n_list = []
for i in range(1,n+1):
n_list.append(i)
for i in range(m):
i , j , k = map(int,input().split())
i -= 1
j -=1
k -=1
tem1 = n_list[i:k]
tem2 = n_list[k:j+1]
if(len(tem2) != 0 and len(tem1) != 0):
n_list[i:i+len(tem2)] = tem2
n_list[i+len(tem2):i+len(tem2)+len(tem1)] = tem1
else:
continue
res = ' '.join(str(s) for s in n_list)
print(res)
#10988번
s = input()
s_list = list(s)
check = 1
for i in range(len(s_list)):
if(s_list[len(s_list)-1-i] != s_list[i]):
check = 0
print(check)
# 1157번 공부해보기
s = input().upper()
s_list = list(set(s))
res_list =[]
for i in s_list:
res_list.append(s.count(i))
if(res_list.count(max(res_list)) > 1):
print("?")
else:
m_index = res_list.index(max(res_list))
print(s_list[m_index])
# 4344번
n = int(input())
for i in range(n):
nums = list(map(int,input().split()))
n_cnt = nums[0]
n_sum = 0
n_avr = 0
for j in range(1,len(nums)):
n_sum += nums[j]
n_avr = n_sum/(n_cnt)
av_cnt = 0
for j in range(1,len(nums)):
if(nums[j] > n_avr):
av_cnt += 1
res = float((av_cnt/n_cnt)*100)
result = str(format(res,".3f"))
print(result+"%")
# 2941번
s = list(input())
c_list = ['c=','c-','dz=','d-','lj','nj','s=','z=']
check = 0
idx = 0
while(len(s) > idx):
if(idx == len(s)-1):
tem = s[idx]
else:
tem = s[idx] + s[idx +1]
if(tem in c_list):
check += 1
idx += 2
elif(tem != 'dz'):
check +=1
idx +=1
else:
if((len(s) - idx) >= 3 and s[idx +2] == '='):
check += 1
idx += 3
else:
check +=1
idx += 1
print(check)
# 1316번
n = int(input())
res = 0
for i in range(n):
s = list(input())
tem_list = []
tem = ''
check = 0
for k in s:
if(k == tem):
continue
elif(k != tem and k not in tem_list):
tem = k
tem_list.append(k)
elif(k != tem and k in tem_list):
check = 1
if(check == 0):
res += 1
print(res)
#25206
score_dic = {"A+":4.5 , "A0":4.0, "B+": 3.5, "B0":3.0, "C+":2.5, "C0":2.0, "D+" : 1.5, "D0":1.0, "F": 0.0, "P": 0.0}
sum_s = 0
sum_c = 0
for i in range(20):
s = list((input().split()))
if(s[2] != "P"):
score = score_dic[s[2]]
sub_score = float(s[1])
tem = (score*sub_score)
sum_s += tem
sum_c += sub_score
print(sum_s/sum_c)