TLE '17 Contest 5 P3 - Willson and Factorization

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Python 2 2.0s
Python 3 2.0s
Memory limit: 256M

Author:
Problem types
Willson is sad because nobody likes him.

Willson the Canada Goose is like any other Canada Goose - he suspects that many humans don't like him.

As a result, he challenges you to do the following problem:

Consider the set Zn={0,1,2,,n1}.

We say that an element u in Zn is a unit if there is some element v in Zn with uv1(modn).

We say that a non-zero, non-unit element i in Zn is irreducible if there are no elements a,b in Zn where a,b are not units and abi(modn).

We say that a non-zero, non-unit element p in Zn is prime if for all elements a,b in Zn, if pxab(modn) for some element x in Zn, then pya(modn) for some element y in Zn or pzb(modn) for some element z in Zn.

Given n, please output all of the units, irreducibles, and primes of Zn.

Input Specification

The only line of input will contain a single integer, n (2n200).

For 20% of the points, n is prime.

For an additional 20% of the points, n15.

For an additional 20% of the points, n50.

Output Specification

Output, in numerical order, first the units, then the irreducibles, then the primes of Zn. See the Sample Output for more specific formatting.

Sample Input 1

Copy
10

Sample Output 1

Copy
Units:
1
3
7
9
Irreducibles:
Primes:
2
4
5
6
8

Sample Input 2

Copy
12

Sample Output 2

Copy
Units:
1
5
7
11
Irreducibles:
2
10
Primes:
2
3
9
10

Comments

There are no comments at the moment.