#include <stdio.h>

int main(void)

{
	int n = 0;
	int sum = 0;
	
	scanf("%d", &n);
	
	if (n>=1 and n<=10000)
	{
		for (int i=1; i<=n; i++)
		{
			sum = sum + i;
		}
		printf("%d", sum);
	}
	
	return 0;
}
# -*- coding:utf-8 -*-
from collections import deque

def bfs() -> list:
    while queue:
        x, y = queue.popleft()

        for i in range(4):
            a = x + dx[i]
            b = y + dy[i]

            if 0<=a<N and 0<=b<M and graph[a][b] == 0:
                queue.append([a, b]) # 방문하지 않은 다음 노드를 큐에 삽입
                graph[a][b] = graph[x][y] + 1

    return graph

if __name__ == "__main__":

    # 초기 변수 선언 & 그래프 생성
    M, N = list(map(int, input().split()))
    graph = []
    queue = deque()

    dx = [-1, 0, 1, 0] # 익은 토마토 좌표 기준으로 사방향 드로잉을 위한 x좌표
    dy = [0, -1, 0, 1] # 익은 토마토 좌표 기준으로 사방향 드로잉을 위한 y좌표

    for i in range(N):
        graph.append(list(map(int,input().split())))

    # 익은 토마토 좌표 추출 -> 큐 삽입

    for i in range(N):
        for j in range(M):
            if graph[i][j] == 1:
                queue.append([i, j])
    
    # 토마토 숙성
    graph = bfs()

    # 결과 출력
    day = 0
    for i in graph:
        for j in i:
            if j == 0:
                print (-1)
                exit(0)
        day = max(day, max(i))
    
    print (day-1)
# -*- coding:utf-8 -*-
import sys
from collections import deque

def breadth_first_seach() -> list:
    while queue:
        z, x, y = queue.popleft()

        for i in range(6):
            a = z + dz[i]
            b = x  +dx[i]
            c = y + dy[i]

            if 0<=a<H and 0<=b<N and 0<=c<M and graph[a][b][c] == 0:
                queue.append([a, b, c])
                graph[a][b][c] = graph[z][x][y] + 1

    return graph


if __name__ == "__main__":

    # N = 행, M = 열, H = 높이
    M, N, H = list(map(int, sys.stdin.readline().split()))
    queue = deque()
    graph = [[[0 for i in range(M)] for j in range(N)] for k in range(H)]

    dx = [-1, 1, 0, 0, 0, 0]
    dy = [0, 0, 1, -1, 0, 0]
    dz = [0, 0, 0, 0, 1, -1]

    for z in range(H):
        for x in range(N): # 행
            graph[z][x] = list(map(int, sys.stdin.readline().split()))
            for y in range(M): # 열
                if graph[z][x][y] == 1:
                    queue.append([z, x, y])

    graph = breadth_first_seach()    
    
    day = 0
    for i in graph:
        for j in i:
            for k in j:
                if k == 0:
                    print (-1)
                    exit(0)
            day = max(day, max(j))
    print (day-1)
import sys

input = sys.stdin.readline
N = int(input())
students :list = [] 

for _ in range(N):
    weight, height = list(map(int, input().split()))
    students.append((weight, height))

for i in students:
    rank = 1
    for j in students:
        if i[0] < j[0] and i[1] < j[1]:
            rank +=1
    
    print (rank, end = " ")
print (124)
print ("roytravel")
import sys
from itertools import combinations

def dfs(start):
    if len(picked) == 6:
        print (*picked)
        return

    for i in range(start, len(test_case)):
        picked.append(test_case[i])
        dfs(i+1)
        picked.pop()

if __name__ == "__main__":
    # 1. manual dfs algorithm for combination
    input = sys.stdin.readline

    while True:
        test_case = list(map(int, input().split()))
        if len(test_case) == 1:
            break

        del test_case[0]
        picked = []
        dfs(0)
        print()

    # 2. using library for combination algorithm
    # while True:
    #     test_case = list(map(int, input().split()))
    #     del test_case[0]

    #     combination = combinations(test_case, 6)
    #     for element in combination:
    #         print (*element)

    #     print ()

    #     if not test_case:
    #         break
import sys
input = sys.stdin.readline

word = input()
dial = {1: "", 2:"ABC", 3:"DEF", 4:"GHI", 5:"JKL", 6:"MNO", 7:"PQRS", 8:"TUV", 9:"WXYZ", 0:""}
time = 0
for i in word:
    for key, value in dial.items():    
        if i in value:
            time += key + 1
print (time)
price = int(input())
coins = [500, 100, 50, 10, 5, 1]
change = (1000 - price)
count = 0
for coin in coins:
    Q, R = divmod(change, coin)
    count = count + Q
    change = R
    if R == 0:
        break
print (count)

 

#include <iostream>

#define N 10001
using namespace std;

int solution(int n)
{
	int sum = n;
	
	while(true)
	{
		if (n==0)
			break;
		
		sum = sum + (n % 10); // get the remainder
		n = n / 10; // divide by 10 to get next remainder;
	}
	
	return sum;
}


int main(void)
{
	bool Array[N] = {0, };
	int idx = 0;
	
	for (int i=1; i<N; i++)
	{
		idx = solution(i);
		
		if (idx <= N) // Why always idx is smaller or equal than N?
			Array[idx] = 1; // constructor = 1
	}
	
	for (int j=1; j<N; j++)
	{
		if (!Array[j])
			cout << j << endl;
	}
	
	return 0;
}
#include <iostream>
#include <math.h>
using namespace std;

int main(void)
{
	int C = 0;
	int N = 0;
	
	cin >> C;
	
	for (int i=0; i<C; i++) // This loop means the number of test case.
	{
		cin >> N;
		
		if (N>=1 and N<=1000)
		{
			int Sum = 0;
			double Mean = 0;
			double count = 0;
			double percent = 0;
			
			int Score[N] = {0, };
			
			for (int j=0; j<N; j++) // This loop gets the summation of input values
			{
				cin >> Score[j];
				if (Score[j]< 0 or Score[j]>100)
					return 0;
					
				Sum = Sum + Score[j];
			}
			
			Mean = Sum / N;
			
			for (int k=0; k<N; k++) // This loop gets count of people who has higher value than mean
			{
				if (Score[k] > Mean)
				{
					count = count + 1;
				}
			}
			
			percent = (count/N) * 100;
			cout << fixed;
			cout.precision(3);
			cout << round(percent * 1000) / 1000 << "%" << endl;
		}
	}
	return 0;
}

+ Recent posts