bitset-fixed

Crates.iobitset-fixed
lib.rsbitset-fixed
version0.1.0
sourcesrc
created_at2019-06-27 04:12:04.085216
updated_at2019-06-27 04:12:04.085216
descriptionBitset for DP.
homepage
repository
max_upload_size
id143912
size13,904
(hatoo)

documentation

README

bitset-fixed

Bitset for DP.

Example

Example for AGC20-C

use bitset_fixed::BitSet;
use rand::prelude::*;

fn main() {
    let mut rng = StdRng::seed_from_u64(114514);

    let n: Vec<usize> = (0..25).map(|_| rng.next_u32() as usize % 2000).collect();
    let sum = n.iter().sum::<usize>();

    let mut bitset = BitSet::new(sum + 1);
    bitset.set(0, true);

    for &x in &n {
        bitset |= &(&bitset << x);
    }

    let ans = ((sum + 1) / 2..).find(|&i| bitset[i]).unwrap();

    println!("N = {:?}\nAnswer = {}", n, ans);
}
Commit count: 0

cargo fmt