Monday-Saturday Numbers
Time limit2sMemory limit128 MB
For each number, list the Monday-Saturday numbers that are irreducible divisors within the set of integers congruent to 1 or 6 mod 7.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
An integer that leaves a remainder of or when divided by is called a number. Because that name is awkward, we will call such an integer a Monday-Saturday number.
For two Monday-Saturday numbers and , if there exists a Monday-Saturday number such that , then is called a Monday-Saturday divisor of . In fact, if a Monday-Saturday number divides in the ordinary sense, then is a Monday-Saturday divisor of , and the converse also holds.
A Monday-Saturday prime is a Monday-Saturday number greater than that has no Monday-Saturday divisors other than and itself. If a Monday-Saturday number is prime in the ordinary sense, then it is a Monday-Saturday prime; however, the converse does not hold. For example, is a Monday-Saturday prime but is not an ordinary prime.
Among the Monday-Saturday divisors of a Monday-Saturday number, those that are Monday-Saturday primes are called its Monday-Saturday prime factors. For example, is a Monday-Saturday prime factor of (since ).
Every Monday-Saturday number greater than can be written as a product of one or more Monday-Saturday primes, but this representation is not unique. For example, .
Given a Monday-Saturday number, write a program that finds all of its Monday-Saturday prime factors.
Input
The input consists of several test cases. Each test case is a single line containing one Monday-Saturday number. This number is greater than and less than . The last line of the input contains , which should not be processed.
Output
For each test case, print the given Monday-Saturday number followed by :, and then print its Monday-Saturday prime factors in ascending order. Print a single space before each Monday-Saturday prime factor.