Skip to content

Instantly share code, notes, and snippets.

@tokugh
Created July 7, 2021 17:51
Show Gist options
  • Save tokugh/d0b877d38ef4750985f22a4f6ab9113a to your computer and use it in GitHub Desktop.
Save tokugh/d0b877d38ef4750985f22a4f6ab9113a to your computer and use it in GitHub Desktop.
fn main() {
proconio::input! {
_n: usize,
s: String,
}
let mut cnt: i64 = 0;
for (i, c) in s.chars().enumerate() {
match c {
'c' => {cnt += 2 << i;},
'b' => {cnt += 1 << i;},
_ => {},
}
}
println!("{}", cnt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment