AOJ Introduction to Programming Topic # 1, Topic # 2, Topic # 3, Topic # 4

Topic # 1

ITP1_1_A Hello World

Python


print("Hello World")

ITP1_1_B

x cubed

Python


n = int(input())
print(n**3)

ITP1_1_C

Rectangle area and circumference

Python


h, w = list(map(int, input().split()))
print(f"{h * w} {h+h+w+w}")

ITP1_1_D

operator

Python


S = int(input())

h = S // 3600
m = S % 3600 // 60
s = S % 60
print(f"{h}:{m}:{s}")

Topic # 2

ITP1_2_A

Large and small relationship

Python


a, b = list(map(int, input().split()))

if a<b:
    print("a < b")
elif a>b:
    print("a > b")
else:
    print("a == b")

ITP1_2_B

range

Python


a, b, c = list(map(int, input().split()))

if a<b<c:
    print("Yes")
else:
    print("No")

ITP1_2_C

Alignment of three numbers

Python


A = list(map(int, input().split()))

for i in range(1, len(A)):
    v = A[i]
    j = i - 1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
    A[j+1]=v
    
for i in range(0, len(A)):
    if i<len(A)-1:
        print(f"{A[i]} ", end='')
    else:
        print(f"{A[i]}")

ITP1_2_D

Circle in a rectangle

Python


W, H, x, y, r = list(map(int, input().split()))

if 0<=x-r and x+r<=W and 0<=y-r and y+r<=H:
    print("Yes")
else:
    print("No")

Topic # 3

ITP1_3_A

Output of multiple Hello Worlds

Python


for i in range(0, 1000):
    print("Hello World")

ITP1_3_B

Test case output

Python


n = 1
A = [0] * 1
while n > 0:
    n = int(input())
    A.append(n)
    
for i in range(1, len(A)):
    if A[i] != 0:
        print(f"Case {i}: {A[i]}")

ITP1_3_C

Exchange of two numbers

Python


while True:
    a, b = list(map(int, input().split()))
    
    if a==0 and b==0:
        break
    else:
        if a < b:
            print(f"{a} {b}")
        else:
            print(f"{b} {a}")

ITP1_3_D

Number of divisors

Python


a, b, c = list(map(int, input().split()))
ans=0
for i in range(a, b+1):
    if c % i == 0:
        ans += 1
print(ans)

Topic # 4

ITP1_4_A

division

Python


a, b = list(map(int, input().split()))
print(f"{a//b} {a%b} {a/b:.5f}")

ITP1_4_B

Area of a circle and circumference

Python


import math as math
r = float(input())
print(f"{r*r*math.pi:.6f} {2*r*math.pi:.6f}")

ITP1_4_C

calculator

Python


while True:
    a, b, c = list(map(str, input().split()))
    a = int(a)
    c = int(c)
    
    if b=='?':
        break
    elif b=='+':
        print(f"{a+c}")
    elif b=='-':
        print(f"{a-c}")
    elif b=='*':
        print(f"{a*c}")
    elif b=='/':
        print(f"{a//c}")

ITP1_4_D

Minimum value, maximum value, total value

Python


n = int(input())
a = list(map(int, input().split()))

Min = 1000000
Max = -1000000
Sum = 0
for i in range(0, n):
    Min = min(Min, a[i])
    Max = max(Max, a[i])
    Sum += a[i]
    
print(f"{Min} {Max} {Sum}")

Recommended Posts

AOJ Introduction to Programming Topic # 1, Topic # 2, Topic # 3, Topic # 4
AOJ Introduction to Programming Topic # 7, Topic # 8
AOJ Introduction to Programming Topic # 5, Topic # 6
Introduction to AOJ Programming (ALDS1)-# 7 Tree Structure
An introduction to Python Programming
[Introduction to Python3 Day 1] Programming and Python
Introduction to MQTT (Introduction)
Introduction to Scrapy (1)
Introduction to Scrapy (3)
Introduction to Supervisor
Introduction to Tkinter 1: Introduction
Introduction to PyQt
Introduction to Scrapy (2)
[Linux] Introduction to Linux
Introduction to Scrapy (4)
Introduction to discord.py (2)
Introduction to discord.py
An introduction to object-oriented programming for beginners by beginners
Introduction to Programming (Python) TA Tendency for beginners
Introduction to Lightning pytorch
Introduction to Web Scraping
Introduction to Nonparametric Bayes
Introduction to EV3 / MicroPython
Introduction to Python language
Introduction to TensorFlow-Image Recognition
Introduction to OpenCV (python)-(2)
Introduction to PyQt4 Part 1
Introduction to Dependency Injection
Introduction to Private Chainer
Introduction to machine learning
Introduction to electronic paper modules
A quick introduction to pytest-mock
Introduction to dictionary lookup algorithm
Introduction to Monte Carlo Method
[Learning memorandum] Introduction to vim
Introduction to PyTorch (1) Automatic differentiation
opencv-python Introduction to image processing
Introduction to Python Django (2) Win
Introduction to Cython Writing [Notes]
An introduction to private TensorFlow
Kubernetes Scheduler Introduction to Homebrew
An introduction to machine learning
[Introduction to cx_Oracle] Overview of cx_Oracle
A super introduction to Linux
[Introduction to pytorch-lightning] First Lit ♬
Introduction to Anomaly Detection 1 Basics
Introduction to RDB with sqlalchemy Ⅰ
[Introduction to Systre] Fibonacci Retracement ♬
Introduction to Nonlinear Optimization (I)
Introduction to serial communication [Python]
An introduction to functional programming to improve debugging efficiency in 1 minute
Programming problem collection (Q16 to Q20)
Introduction to Deep Learning ~ Learning Rules ~
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
[Introduction to cx_Oracle] (8th) cx_Oracle 8.0 release
Introduction to discord.py (3) Using voice
An introduction to Bayesian optimization
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
Super introduction to machine learning
Introduction to Ansible Part ③'Inventory'