use std::io::{self, BufRead, Write};
fn encode(x: u32) -> u32 {
(x % 1000) + 1
}
fn decode(x: u32) -> u32 {
if x == 1 {
1000
} else {
x - 1
}
}
fn main() {
let stdin = io::stdin();
let mut lines = stdin.lock().lines();
let name = lines.next().unwrap().unwrap();
let nums = lines.next().unwrap().unwrap();
let mut it = nums.split_whitespace();
let a: u32 = it.next().unwrap().parse().unwrap();
let b: u32 = it.next().unwrap().parse().unwrap();
let mut out = io::BufWriter::new(io::stdout());
if name == "Algosia" {
writeln!(out, "{} {}", encode(a), encode(b)).unwrap();
} else if name == "Bajtek" {
writeln!(out, "{} {}", decode(a), decode(b)).unwrap();
}
out.flush().unwrap();
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | use std::io::{self, BufRead, Write}; fn encode(x: u32) -> u32 { (x % 1000) + 1 } fn decode(x: u32) -> u32 { if x == 1 { 1000 } else { x - 1 } } fn main() { let stdin = io::stdin(); let mut lines = stdin.lock().lines(); let name = lines.next().unwrap().unwrap(); let nums = lines.next().unwrap().unwrap(); let mut it = nums.split_whitespace(); let a: u32 = it.next().unwrap().parse().unwrap(); let b: u32 = it.next().unwrap().parse().unwrap(); let mut out = io::BufWriter::new(io::stdout()); if name == "Algosia" { writeln!(out, "{} {}", encode(a), encode(b)).unwrap(); } else if name == "Bajtek" { writeln!(out, "{} {}", decode(a), decode(b)).unwrap(); } out.flush().unwrap(); } |
English