forked from m-thu/sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatsq.c
121 lines (86 loc) · 1.23 KB
/
matsq.c
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
/*
!
( a b )^2 = ( aa bb )
( c d ) ( cc dd )
( a b ) * ( a b ) = ( a*a + b*c a*b + b*d )
( c d ) ( c d ) ( c*a + d*c c*b + d*d )
*/
int main()
{
uint64_t a, b, c, d;
uint64_t x11, x12, x21, x22;
for (a = 0; a < 10; ++a)
for (b = 0; b < 10; ++b)
for (c = 0; c < 10; ++c)
for (d = 0; d < 10; ++d) {
x11 = a*a + b*c;
x12 = a*b + b*d;
x21 = c*a + d*c;
x22 = c*b + d*d;
if ((a*11 == x11) &&
(b*11 == x12) &&
(c*11 == x21) &&
(d*11 == x22)) {
printf(" ( %"PRIu64" %"PRIu64" )\n", a, b);
printf(" ( %"PRIu64" %"PRIu64" )\n\n", c, d);
}
}
return 0;
}
/*
gcc -Wall -std=c99 -pedantic -Wextra -O3 matsq.c
./a.out
( 0 0 )
( 0 0 )
( 2 2 )
( 9 9 )
( 2 3 )
( 6 9 )
( 2 6 )
( 3 9 )
( 2 9 )
( 2 9 )
( 3 3 )
( 8 8 )
( 3 4 )
( 6 8 )
( 3 6 )
( 4 8 )
( 3 8 )
( 3 8 )
( 4 4 )
( 7 7 )
( 4 7 )
( 4 7 )
( 5 5 )
( 6 6 )
( 5 6 )
( 5 6 )
( 6 5 )
( 6 5 )
( 6 6 )
( 5 5 )
( 7 4 )
( 7 4 )
( 7 7 )
( 4 4 )
( 8 3 )
( 8 3 )
( 8 4 )
( 6 3 )
( 8 6 )
( 4 3 )
( 8 8 )
( 3 3 )
( 9 2 )
( 9 2 )
( 9 3 )
( 6 2 )
( 9 6 )
( 3 2 )
( 9 9 )
( 2 2 )
*/