about summary refs log tree commit diff
path: root/2ndary/THT/B/QG-2016/trigrid.c
blob: 15ad5529eba05a3636279905b9098942530b8bd7 (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, 3, 5, 6, 111, 222, 3333, 4444, 55555, 666666,
                           7777777, 88888888, 999999999, 123456789123456789,
                           1000000000000000000};

long long quadratic(long long x, char a, char b, char c)
{
	return a * x * x + b * x + c;
}

int main()
{
	char i;
	long long k, q;
	FILE *f;

	f = fopen("TRIGRID.TXT", "w");

	for (i = 0; i < 15; i++) {
		q = TESTS[i] % 2016;
		k = TESTS[i] / 2016 % 2016 * 252 * quadratic(q, 6, 10, 2);
		fprintf(f, "%d\n", (k + quadratic(q, 2, 5, 2) * q / 8) % 2016);
	}

	fclose(f);

	return 0;
}