Clarify comment
This commit is contained in:
parent
ab6ab1f4ad
commit
8338e81670
8
C/p015.c
8
C/p015.c
@ -1,3 +1,6 @@
|
||||
/* Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner
|
||||
* How many such routes are there through a 20×20 grid?*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
@ -11,6 +14,11 @@ int main(int argc, char **argv)
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
|
||||
/* Using a combinatorial solution: in a 20x20 grid there will always be
|
||||
* 20 movements to the right and 20 movements down, that can be represented
|
||||
* as a string of Rs and Ds. The number of routes is the number of combinations.
|
||||
* This is obtained calculating n!/(k!*(n-k)!), where n=40 and k=20. The GMP
|
||||
* Library is used to calculate the factorials.*/
|
||||
mpz_inits(count, tmp, NULL);
|
||||
mpz_fac_ui(count, 40);
|
||||
mpz_fac_ui(tmp, 20);
|
||||
|
Loading…
x
Reference in New Issue
Block a user