https://github.com/hatoo/bitset-fixed
Bitset for DP
https://github.com/hatoo/bitset-fixed
Last synced: 12 months ago
JSON representation
Bitset for DP
- Host: GitHub
- URL: https://github.com/hatoo/bitset-fixed
- Owner: hatoo
- Created: 2019-05-31T14:27:56.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-30T08:07:58.000Z (over 6 years ago)
- Last Synced: 2025-03-23T12:30:10.840Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
bitset-fixed
===
**Under developing**
Bitset for DP.
## Example
Example for AGC20-C
```rust
use bitset_fixed::BitSet;
use rand::prelude::*;
fn main() {
let mut rng = StdRng::seed_from_u64(114514);
let n: Vec = (0..25).map(|_| rng.next_u32() as usize % 2000).collect();
let sum = n.iter().sum::();
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);
}
```