pub struct SmallModMemorizedFactorial<M>where
M: MIntConvert<usize>,{ /* private fields */ }
Implementations§
Source§impl<M> SmallModMemorizedFactorial<M>where
M: MIntConvert<usize>,
impl<M> SmallModMemorizedFactorial<M>where
M: MIntConvert<usize>,
pub fn new() -> Self
Sourcepub fn factorial(&self, n: usize) -> (MInt<M>, usize)
pub fn factorial(&self, n: usize) -> (MInt<M>, usize)
n! = a * p^e, c==1
Examples found in repository?
crates/competitive/src/math/factorial.rs (line 135)
129 pub fn factorial(&self, n: usize) -> (MInt<M>, usize) {
130 let p = self.p as usize;
131 if n == 0 {
132 (MInt::<M>::one(), 0)
133 } else {
134 let e = n / p;
135 let res = self.factorial(e);
136 if e % 2 == 0 {
137 (res.0 * self.fact[n % p], res.1 + e)
138 } else {
139 (res.0 * -self.fact[n % p], res.1 + e)
140 }
141 }
142 }
pub fn combination(&self, n: usize, r: usize) -> MInt<M>
Trait Implementations§
Source§impl<M> Clone for SmallModMemorizedFactorial<M>
impl<M> Clone for SmallModMemorizedFactorial<M>
Source§fn clone(&self) -> SmallModMemorizedFactorial<M>
fn clone(&self) -> SmallModMemorizedFactorial<M>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<M> Debug for SmallModMemorizedFactorial<M>
impl<M> Debug for SmallModMemorizedFactorial<M>
Source§impl<M> Default for SmallModMemorizedFactorial<M>where
M: MIntConvert<usize>,
impl<M> Default for SmallModMemorizedFactorial<M>where
M: MIntConvert<usize>,
Auto Trait Implementations§
impl<M> Freeze for SmallModMemorizedFactorial<M>
impl<M> RefUnwindSafe for SmallModMemorizedFactorial<M>
impl<M> Send for SmallModMemorizedFactorial<M>
impl<M> Sync for SmallModMemorizedFactorial<M>
impl<M> Unpin for SmallModMemorizedFactorial<M>
impl<M> UnwindSafe for SmallModMemorizedFactorial<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more