We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

# Connecting Towns

# Connecting Towns

+ 4 comments Pretty annoying, not really a mathematics challenge, but rather a "know-how-to-deal-with-long-integers" challenge.

+ 1 comment If you're failing all but 1 of the test cases, you more than likely did not implement the modulo described in the instructions. In my opinion this problem would be much better if we didn't have to handle data overflow in such a way. In any case it's only 1 extra line of code:

var routeCount=1; for(int i=0;i<routes.Length;i++){ routeCount*=routes[i]; routeCount%=1234567; } return routeCount;

+ 1 comment **For C# LINQ**int result = arr.Aggregate(1, (a, b) => (b * a)%1234567);

+ 0 comments connectingTowns(n, routes): p = 1 for x in range(n-1): p = p * routes[x] return p%1234567

lol..what a troll, this is just the number of ways to walk routes. hahahhaahahaha

+ 2 comments Snippet.

for(int j = 0; j < towns - 1; j++) { routes *= scanner.nextInt(); for(;;) { if (routes > 1234567) routes = routes - 1234567; else break; } }

Load more conversations

Sort 139 Discussions, By:

Please Login in order to post a comment