#![allow(unused_macros)] #![allow(dead_code)] #![allow(unused_imports)] // # ファイル構成 // - use 宣言 // - lib モジュール // - main 関数 // - basic モジュール // // 常に使うテンプレートライブラリは basic モジュール内にあります。 // 問題に応じて使うライブラリ lib モジュール内にコピペしています。 // ライブラリのコードはこちら → https://github.com/RheoTommy/at_coder // Twitter はこちら → https://twitter.com/RheoTommy use std::collections::*; use std::io::{stdout, BufWriter, Write}; use crate::basic::*; use crate::lib::*; pub mod lib { /// O(logN) pub fn pow(mut x: i64, mut n: u64) -> i64 { let mut res = 1; while n != 0 { if n & 1 == 1 { res *= x; } n /= 2; x *= x; } res } /// O(logN) pub fn mod_pow(mut x: i64, mut n: u64, m: i64) -> i64 { let mut res = 1; while n != 0 { if n & 1 == 1 { res *= x; } n /= 2; x *= x; res %= m; x %= m; } res % m } /// O(logN) pub fn gcd(mut a: u64, mut b: u64) -> u64 { while b != 0 { let tmp = b; b = a % b; a = tmp; } a } /// O(logN) pub fn lcm(a: u64, b: u64) -> u64 { let g = gcd(a, b); a * b / g } /// O(logN) pub fn ext_gcd(a: i64, b: i64) -> (i64, i64, i64) { if b == 0 { return if a < 0 { (-a, -1, 0) } else { (a, 1, 0) }; } let (g, s, t) = ext_gcd(b, a % b); (g, t, s - (a / b) * t) } pub fn mod_inv(a: i64, m: i64) -> Option { let (g, xi, _) = ext_gcd(a, -m); if g != 1 { None } else { Some((xi % m + m) % m) } } pub fn mod_div(a: i64, b: i64, n: i64) -> Option { let d = gcd(gcd(a.abs() as u64, b.abs() as u64), n.abs() as u64) as i64; let inv = mod_inv(a / d, n / d)?; let n = n / d; Some(((inv * b / d) % n + n) % n) } /// O(√NlogN) pub fn divisors(n: u64) -> Vec { let mut res = Vec::new(); for i in 1.. { if i * i > n { break; } if n % i == 0 { res.push(i); if n / i != i { res.push(n / i); } } } res.sort_unstable(); res } /// O(√N) pub fn is_prime(n: u64) -> bool { for i in 2.. { if i * i > n { break; } if n % i == 0 { return false; } } n > 1 } /// O(√N) pub fn factorization(mut n: u64) -> std::collections::HashMap { let mut res = std::collections::HashMap::new(); for i in 2.. { if i * i > n { break; } let mut ex = 0; while n % i == 0 { ex += 1; n /= i; } if ex != 0 { res.insert(i, ex); } } if n != 0 { *res.entry(n).or_insert(0) += 1; } res.remove(&1); res } pub fn float_to_int(s: &[char], x: u32) -> i64 { if !s.contains(&'.') { return s.iter().collect::().parse::().unwrap() * 10i64.pow(x); } let n = s.len(); let i = s.iter().enumerate().find(|(_, ci)| **ci == '.').unwrap().0; let l = n - i - 1; let t = s .iter() .skip_while(|ci| **ci == '0') .filter(|ci| **ci != '.') .collect::() .parse::() .unwrap() * 10i64.pow(x - l as u32); t } } fn main() { let mut io = IO::new(); let s = io.next_chars().collect::>(); let a = float_to_int(&s, 3); let h = lcm(a as u64, 1000) as i64; let w = h / a; // eprintln!("{:?}", (a, h, w)); let h = h / 1000; let w = w; let d = w - 1 + h - 1 + (h + w) / 2 + (h - w).abs() / 2; let p = [['A', 'B'], ['C', 'A']]; io.println(format!("{} {}", p[h as usize % 2][w as usize % 2], d)); } pub mod basic { pub const U_INF: u64 = (1 << 60) + (1 << 30); pub const I_INF: i64 = (1 << 60) + (1 << 30); pub struct IO { iter: std::str::SplitAsciiWhitespace<'static>, buf: std::io::BufWriter>, } impl Default for IO { fn default() -> Self { Self::new() } } impl IO { pub fn new() -> Self { use std::io::*; let mut input = String::new(); std::io::stdin().read_to_string(&mut input).unwrap(); let input = Box::leak(input.into_boxed_str()); let out = Box::new(stdout()); IO { iter: input.split_ascii_whitespace(), buf: BufWriter::new(Box::leak(out).lock()), } } pub fn next_str(&mut self) -> &str { self.iter.next().unwrap() } pub fn read(&mut self) -> T where ::Err: std::fmt::Debug, { self.iter.next().unwrap().parse().unwrap() } pub fn next_usize(&mut self) -> usize { self.read() } pub fn next_uint(&mut self) -> u64 { self.read() } pub fn next_int(&mut self) -> i64 { self.read() } pub fn next_float(&mut self) -> f64 { self.read() } pub fn next_chars(&mut self) -> std::str::Chars { self.next_str().chars() } pub fn next_vec(&mut self, n: usize) -> Vec where ::Err: std::fmt::Debug, { (0..n).map(|_| self.read()).collect::>() } pub fn print(&mut self, t: T) { use std::io::Write; write!(self.buf, "{}", t).unwrap(); } pub fn println(&mut self, t: T) { self.print(t); self.print("\n"); } pub fn print_iter>( &mut self, mut iter: I, sep: &str, ) { if let Some(v) = iter.next() { self.print(v); for vi in iter { self.print(sep); self.print(vi); } } self.print("\n"); } pub fn flush(&mut self) { use std::io::Write; self.buf.flush().unwrap(); } } }