아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Ordered Fractions

면접 대비

시간 제한1초메모리 제한1024 MB

요약
N이 주어질 때 분모가 N 이하인 0과 1 사이의 기약분수를 모두 세고 오름차순으로 나열한다.
난이도

보통10점 중 5점

유형
수학, 정수론, 정렬, 조합론
정답자
아직 제출이 없습니다

문제

Consider the set of all reduced fractions (rational numbers) between 0 and 1 inclusive with denominators less than or equal to N.

Here is the proper set when N = 5:

0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/3 3/4 4/5 1/1

Write a program that, given an integer N between 1 and 500 inclusive, prints the total number of fractions, orders them, and prints a few of them to prove that your program can order them correctly.

입력

The only line contains one integer, N.

출력

On the first line of the output, print the total number of fractions per the rules above. Subsequent lines should print every fraction from the ordered list, starting with the first fraction.

예제1

  1. 예제 1

    입력
    5
    
    예상 출력
    11
    0/1
    1/5
    1/4
    1/3
    2/5
    1/2
    3/5
    2/3
    3/4
    4/5
    1/1