about summary refs log tree commit diff
path: root/12/Q-VĩnhTường-2006/cau3.c
blob: 136f154a50e53749de107a3b0d33769269f1952e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <math.h>

const char PRIMES[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main()
{
	char i;
	short n, n0;

	scanf("%hd", &n);

	if (n < 2) {
		printf("\n%hd\n", n);

		return 0;
	}

	n0 = n;

	for (i = 0; i < 11; i++)
		while (n0 % PRIMES[i] == 0) {
			n0 /= PRIMES[i];
			printf("%hd ", PRIMES[i]);
		}

	if (n0 - 1)
		printf("%hd\n", n0);
	else
		putchar(10);

	n0 = pow(2, (int) log2(n) - 1);

	if (n0 * 3 > n)
		printf("%hd\n", n0 * 2);
	else
		printf("%hd %hd\n", n0 * 2, n0 * 3);

	return 0;
}