File tree Expand file tree Collapse file tree 4 files changed +108
-1
lines changed Expand file tree Collapse file tree 4 files changed +108
-1
lines changed Original file line number Diff line number Diff line change 32
32
id0068$(E ) id0069$(E ) id0070$(E ) id0071$(E ) id0072$(E ) id0073$(E ) \
33
33
id0074$(E ) id0075$(E ) id0076$(E ) id0077$(E ) id0078$(E ) id0079$(E ) \
34
34
id0080$(E ) id0081$(E ) id0082$(E ) id0083$(E ) id0084$(E ) id0085$(E ) \
35
- id0086$(E ) id0087$(E ) id0089$(E )
35
+ id0086$(E ) id0087$(E ) id0089$(E ) id0091 $( E ) id0092 $( E )
36
36
37
37
libeuler$(A ) : $(call RECURSE,lib,* .c)
38
38
$(RM ) * .o
@@ -306,5 +306,11 @@ id0087$(E): src/id0087.c libeuler$(A)
306
306
id0089$(E ) : src/id0089.c libeuler$(A )
307
307
$(CC ) $(CFLAGS ) $< -o $@ $(LEULER ) $(LM )
308
308
309
+ id0091$(E ) : src/id0091.c libeuler$(A )
310
+ $(CC ) $(CFLAGS ) $< -o $@ $(LEULER ) $(LM )
311
+
312
+ id0092$(E ) : src/id0092.c libeuler$(A )
313
+ $(CC ) $(CFLAGS ) $< -o $@ $(LEULER ) $(LM )
314
+
309
315
clean :
310
316
$(RM ) * $(A ) * .o
Original file line number Diff line number Diff line change @@ -122,6 +122,8 @@ which is licensed under the GNU Lesser General Public License v3.0 (`LGPL-3.0`).
122
122
| 86 | [ Cuboid Route] ( src/id0086.c ) | Geometry | Minimum | |
123
123
| 87 | [ Prime Power Triples] ( src/id0087.c ) | Number theory | Count | [ Hash set] ( https://en.wikipedia.org/wiki/Hash_table ) |
124
124
| 89 | [ Roman Numerals] ( src/id0089.c ) | Numeral systems | Difference | [ Roman numerals] ( https://en.wikipedia.org/wiki/Roman_numerals ) |
125
+ | 91 | [ Right Triangles with Integer Coordinates] ( src/id0091.c ) | Geometry | Count | |
126
+ | 92 | [ Square Digit Chains] ( src/id0092.c ) | Number theory | Count | |
125
127
126
128
## LeetCode
127
129
@@ -142,6 +144,7 @@ which is licensed under the GNU Lesser General Public License v3.0 (`LGPL-3.0`).
142
144
| 62 | [ Unique Paths] ( src/lc0062.c ) | Combinatorics | Binomial coefficient | ` binomial ` |
143
145
| 69 | [ Sqrt(x)] ( src/lc0069.c ) | Mathematics | Square root | ` sqrt ` |
144
146
| 75 | [ Sort Colors] ( src/lc0075.c ) | Sorting | Sort | ` qsort ` |
147
+ | 273 | [ Integer to English Words] ( src/lc0273.c ) | Mathematics | String | ` words_to_string ` |
145
148
| 367 | [ Valid Perfect Square] ( src/lc0367.c ) | Mathematics | Boolean | ` math_is_polygonal ` |
146
149
| 2119 | [ A Number After a Double Reversal] ( src/lc2119.c ) | Mathematics | Boolean | ` math_reverse ` |
147
150
| 2400 | [ Number of Ways to Reach a Position After Exactly k Steps] ( src/lc2400.c ) | Combinatorics | Binomial coefficient | ` mod_binomial_range ` |
Original file line number Diff line number Diff line change
1
+ // Licensed under the MIT License.
2
+
3
+ // Right Triangles with Integer Coordinates
4
+
5
+ #include "../lib/euler.h"
6
+ #include "../lib/euclidean.h"
7
+
8
+ int main (void )
9
+ {
10
+ int count = 0 ;
11
+ clock_t start = clock ();
12
+
13
+ for (int x = 1 ; x <= 50 ; x ++ )
14
+ {
15
+ for (int y = 1 ; y <= 50 ; y ++ )
16
+ {
17
+ int d = gcd (x , y );
18
+ int min = x * d / y ;
19
+ int other = (50 - y ) * d / x ;
20
+
21
+ if (other < min )
22
+ {
23
+ min = other ;
24
+ }
25
+
26
+ count += 2 * min ;
27
+ }
28
+ }
29
+
30
+ count += 50 * 50 * 3 ;
31
+
32
+ return euler_submit (91 , count , start );
33
+ }
Original file line number Diff line number Diff line change
1
+ // Licensed under the MIT License.
2
+
3
+ // Square Digit Chains
4
+
5
+ #include "../lib/euler.h"
6
+
7
+ int math_sum_of_square_digits (long n , int results [])
8
+ {
9
+ if (n < 568 && results [n ])
10
+ {
11
+ return results [n ];
12
+ }
13
+
14
+ long result = 0 ;
15
+
16
+ for (long k = n ; k ; k /= 10 )
17
+ {
18
+ int d = k % 10 ;
19
+
20
+ result += d * d ;
21
+ }
22
+
23
+ return result ;
24
+ }
25
+
26
+ int math_square_digit_chain (long m , int results [])
27
+ {
28
+ long n = m ;
29
+
30
+ while (n != 1 && n != 89 )
31
+ {
32
+ n = math_sum_of_square_digits (n , results );
33
+ }
34
+
35
+ return n ;
36
+ }
37
+
38
+ int main (void )
39
+ {
40
+ long count = 0 ;
41
+ int results [568 ] = { 0 };
42
+ clock_t start = clock ();
43
+
44
+ for (long m = 1 ; m < 568 ; m ++ )
45
+ {
46
+ results [m ] = math_square_digit_chain (m , results );
47
+
48
+ if (results [m ] == 89 )
49
+ {
50
+ count ++ ;
51
+ }
52
+ }
53
+
54
+ for (long m = 1 ; m < 10000000l ; m ++ )
55
+ {
56
+ long n = math_square_digit_chain (m , results );
57
+
58
+ if (n == 89 )
59
+ {
60
+ count ++ ;
61
+ }
62
+ }
63
+
64
+ return euler_submit (91 , count , start );
65
+ }
You can’t perform that action at this time.
0 commit comments