diff --git a/atcoder/beginner_contests/abc042/Cargo.lock b/atcoder/beginner_contests/abc042/Cargo.lock new file mode 100644 index 0000000..1174a44 --- /dev/null +++ b/atcoder/beginner_contests/abc042/Cargo.lock @@ -0,0 +1,25 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "abc042" +version = "0.1.0" +dependencies = [ + "proconio", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "proconio" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c333be3af2936f8e810300bc74fe4d0cc168ebc04ab02a28c5b1060fa1bd59" +dependencies = [ + "lazy_static", +] diff --git a/atcoder/beginner_contests/abc042/Cargo.toml b/atcoder/beginner_contests/abc042/Cargo.toml new file mode 100644 index 0000000..00edab5 --- /dev/null +++ b/atcoder/beginner_contests/abc042/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "abc042" +version = "0.1.0" +edition = "2021" + +# dependencies added to new project +[dependencies] +proconio = "0.4.3" + +[profile.release] +lto = true +panic = 'abort' diff --git a/atcoder/beginner_contests/abc042/src/bin/a.rs b/atcoder/beginner_contests/abc042/src/bin/a.rs new file mode 100644 index 0000000..b81c519 --- /dev/null +++ b/atcoder/beginner_contests/abc042/src/bin/a.rs @@ -0,0 +1,11 @@ +use proconio::input; + +fn main() { + input!{ + mut abc: [u8; 3], + }; + abc.sort(); + let ans = abc == vec![5, 5, 7]; + + println!("{}", if ans {"YES"} else {"NO"}); +} diff --git a/atcoder/beginner_contests/abc042/src/bin/b.rs b/atcoder/beginner_contests/abc042/src/bin/b.rs new file mode 100644 index 0000000..8a97063 --- /dev/null +++ b/atcoder/beginner_contests/abc042/src/bin/b.rs @@ -0,0 +1,14 @@ +use proconio::input; + +fn main() { + input!{ + n: u8, + _l: u8, + mut s: [String; n], + }; + + s.sort(); + for substring in s { + print!("{}", substring); + } +} diff --git a/atcoder/beginner_contests/abc042/src/bin/c.rs b/atcoder/beginner_contests/abc042/src/bin/c.rs new file mode 100644 index 0000000..004dfe0 --- /dev/null +++ b/atcoder/beginner_contests/abc042/src/bin/c.rs @@ -0,0 +1,40 @@ +use proconio::input; + +fn check_number(n: u32, likes: &[bool; 10]) -> bool { + let mut result = true; + + let mut m = n; + while m > 0 { + let l = m % 10; + + if !likes[l as usize] { + result = false; + break; + } + + m /= 10; + } + + result +} + +fn main() { + input!{ + mut n: u32, + k: u32, + d: [u32; k], + }; + + let mut likes = [true; 10]; + for dislike in d { + likes[dislike as usize] = false; + } + + let mut check = false; + while !check { + check = check_number(n, &likes); + n += 1; + } + + print!("{}", n - 1); +} diff --git a/atcoder/beginner_contests/abc042/src/bin/d.rs b/atcoder/beginner_contests/abc042/src/bin/d.rs new file mode 100644 index 0000000..5de5197 --- /dev/null +++ b/atcoder/beginner_contests/abc042/src/bin/d.rs @@ -0,0 +1,43 @@ +use proconio::input; + +const MAX: u128 = u128::pow(10, 9) + 7; + +fn main() { + input!{ + h: u128, + w: u128, + a: u128, + b: u128, + }; + + // Ok it seems like this way is too naive for this problem and I actually have + // to do some magic with combinations or something else I haven't even thought of + + // But I don't think you can do combinations because you need to divide big numbers + // and you can't do that with modulo iirc + + let mut dp = vec![vec![0; w as usize]; h as usize]; + for i in 0..(h-a) { + dp[i as usize][0] = 1; + } + for j in 0..w { + dp[0][j as usize] = 1; + } + + for i in 1..h { + for j in 1..w { + if !(i >= h - a && j < b) { + dp[i as usize][j as usize] = (dp[(i - 1) as usize][j as usize] + dp[i as usize][(j - 1) as usize]) % MAX; + } + } + } + + // for row in &dp { + // for cell in row { + // print!("{} ", {cell}); + // } + // print!("\n"); + // } + + println!("{}", {dp[(h-1) as usize][(w-1) as usize]}); +} \ No newline at end of file