solutions: 318A
This commit is contained in:
parent
dace217df8
commit
e5b5366785
1 changed files with 20 additions and 0 deletions
20
solutions/rust/318A.rs
Normal file
20
solutions/rust/318A.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
use std::io;
|
||||
|
||||
fn main() {
|
||||
let mut s = String::new();
|
||||
io::stdin().read_line(&mut s).unwrap();
|
||||
|
||||
let input = s.trim().split_whitespace().map(|s| s.parse::<u64>().unwrap()).collect::<Vec<u64>>();
|
||||
let n = input[0];
|
||||
let k = input[1];
|
||||
|
||||
if k > (((n as f64/ 2.).ceil() as u64)) {
|
||||
if n % 2 == 0 {
|
||||
println!("{}", (2*(k-(n/2))))
|
||||
} else {
|
||||
println!("{}", (2*(k-((n+1)/2))))
|
||||
}
|
||||
} else {
|
||||
println!("{}", (2*k-1))
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue