init
This commit is contained in:
7
problems/p76/Cargo.toml
Normal file
7
problems/p76/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "p76"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
num-bigint = { workspace = true }
|
||||
24
problems/p76/src/main.rs
Normal file
24
problems/p76/src/main.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
// 2 -> 1: 1 + 1
|
||||
// 3 -> 2: 2 + 1, 1 + 1 + 1
|
||||
// 4 -> 4: 3 + 1, 2 + 2, 2 + 1 + 1, 1 + 1 + 1 + 1
|
||||
// 5 -> 4: 4 + 1, 3 + 2, 3 + 1 + 1, 2 + 2 + 1,
|
||||
// n -> x: (n-1) + 1,
|
||||
use num_bigint::BigUint;
|
||||
|
||||
fn split(n: u64) -> BigUint {
|
||||
let n = n as usize;
|
||||
let mut dp = vec![BigUint::ZERO; n + 1];
|
||||
dp[0] = BigUint::from(1u32);
|
||||
for i in 1..n {
|
||||
for j in i..=n {
|
||||
let temp = dp[j - i].clone();
|
||||
dp[j] += temp;
|
||||
}
|
||||
}
|
||||
dp[n].clone()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let result = split(100);
|
||||
println!("{result}");
|
||||
}
|
||||
Reference in New Issue
Block a user