about summary refs log tree commit diff
path: root/2ndary/THT/B/QG-2014/giaodiem.c
blob: 78ca9b2fe0f455dfce9e0419825b25c2ae831973 (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
#include <stdio.h>

const long long TESTS[] = {4, 7, 10, 11, 7777, 8888888, 1234567890, 9999999999,
                           12345678912345, 2014201420142014};

int main()
{
	char i, j, k, divisor;
	long long n, p;
	FILE *f = fopen("GIAODIEM.TXT", "w");

	for (i = 0; i < 10; i++) {
		divisor = 24;
		p = 1;
		for (j = 0; j < 4; j++) {
			n = TESTS[i] - j;
			for (k = 2; k < 4; k++) {
				while (!(n % k + divisor % k)) {
					n /= k;
					divisor /= k;
				}
			}
			p *= n % 2014;
		}
		fprintf(f, "%d\n", p % 2014);
	}
	fclose(f);
	return 0;
}