Solve ABC036 A ~ C in Python

Introduction

long time no see. It turned brown, so I skipped it a little. Today we will solve it as ABC036.

A problem

Problem

** Thoughts ** Round up with ceil and divide.

import math
a, b = map(int,input().split())

print(math.ceil(b/a))

B problem

Problem

** Thoughts ** Just swap the vertical and horizontal with for.

n = int(input())
s = [list(input()) for _ in range(n)]

d = []
for i in range(n):
    c = []
    for j in range(n):
        c.append(s[j][i])
    c = c[::-1]
    d.append(c)

ans = ''
for i in range(n):
    s = ''.join(d[i])
    print(s)

C problem

Problem

** Thoughts ** Commentary AC. It was easy with dict. I did not know. Delete the duplicate elements of $ a $ with set, sort them, and put them in the dict in order.

n = int(input())
a = [int(input()) for _ in range(n)]
s = sorted(list(set(a))) #set
dic = {}

for i, e in enumerate(s): #You can minimize the number by using enumerate.
    dic[e] = i
for i in a:
    print(dic[i])

Summary

I am not familiar with data structures, so I will study. Aim green! Good night yet.

Recommended Posts

Solve ABC036 A ~ C in Python
Solve ABC037 A ~ C in Python
Solve ABC175 A, B, C in Python
Solve ABC163 A ~ C with Python
ABC166 in Python A ~ C problem
Solve ABC168 A ~ C with Python
Solve ABC162 A ~ C with Python
Solve ABC167 A ~ C with Python
Solve ABC158 A ~ C with Python
Solve ABC169 in Python
Solve Atcoder ABC176 (A, B, C, E) in Python
Solve ABC165 A, B, D in Python
Solve ABC176 E in Python
ABC127 A, B, C Explanation (python)
ABC128 A, B, C commentary (python)
ABC126 A, B, C Explanation (python)
ABC 157 D --Solve Friend Suggestions in Python!
Algorithm in Python (ABC 146 C Binary Search
[AtCoder] Solve ABC1 ~ 100 A problem with Python
I wanted to solve ABC159 in Python
Solve AtCoder ABC168 with python (A ~ D)
Solve ABC168D in Python
Solve ABC167-D in Python
Solve ABC146-C in Python
Solve ABC098-C in Python
Solve ABC159-D in Python
C API in Python 3
ABC147 C --HonestOrUnkind2 [Python]
Solve ABC160-E in Python
[AtCoder] Solve A problem of ABC101 ~ 169 with Python
Call a Python script from Embedded Python in C ++ / C ++
I tried adding a Python3 module in C
Challenge AtCoder (ABC) 164 with Python! A ~ C problem
Extend python in C ++ (Boost.NumPy)
AtCoder ABC 177 Python (A ~ E)
Take a screenshot in Python
Solve AtCoder ABC166 with python
Create a function in Python
Create a dictionary in Python
ABC163 C problem with python3
AtCoder ABC 178 Python (A ~ E)
Atcoder ABC164 A-C in Python
ABC129 A, B, C commentary
ABC memorandum [ABC163 C --managementr] (Python)
AtCoder ABC 176 Python (A ~ E)
Atcoder ABC167 A-D in Python
Solve Wooldridge exercises in Python
Make a bookmarklet in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
AtCoder ABC 182 Python (A ~ D)
Solve optimization problems in Python
Draw a heart in Python
ABC188 C problem with python3
Solve AtCoder ABC 186 with Python
ABC187 C problem with python
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
Try embedding Python in a C ++ program with pybind11
Maybe in a python (original title: Maybe in Python)
Write a binary search in Python