Finished abc051 b very dirty, first look at c

This commit is contained in:
2023-05-05 16:58:48 +02:00
parent 3abb97ae34
commit 10d9d26c5e
2 changed files with 21 additions and 3 deletions

View File

@@ -1,7 +1,19 @@
use proconio::input;
use std::cmp::min;
fn solve(k: u32, s: u32) -> u32 {
let mut result = 0;
let low = s - min(s, 2 * k);
for i in low..=k {
for j in low..=k {
for h in low..=k {
if i + j + h == s {
result += 1;
}
}
}
}
return result;
}
@@ -13,7 +25,6 @@ fn main() {
};
assert!(s <= 3 * k);
println!("{}", solve(k, s));
println!("{}", solve(k, s));
}