Dinesman's multiple-dwelling problem: Difference between revisions
Content added Content deleted
m (→{{header|D}}) |
(→{{header|D}}: fix overflow issue) |
||
Line 131: | Line 131: | ||
<lang d>import std.stdio, std.exception, std.range, std.algorithm, std.math; |
<lang d>import std.stdio, std.exception, std.range, std.algorithm, std.math; |
||
pure |
pure ulong fact(uint n) { |
||
ulong result = 1; |
|||
for ( |
for (uint i = 2; i <= n; i++) |
||
result *= i; |
result *= i; |
||
return result; |
return result; |
||
Line 140: | Line 140: | ||
struct LazyPermutation { |
struct LazyPermutation { |
||
private uint[] seq; |
private uint[] seq; |
||
private |
private ulong tot; |
||
private size_t num; |
private size_t num; |
||