fork download
  1. fn _to_s(acc: String, n: i64, b: i64, cs: &Vec<char>) -> String {
  2. match n {
  3. 0 => acc,
  4. _ => _to_s(cs[(n % b) as usize].to_string() + &acc, n / b, b, cs)
  5. }
  6. }
  7. fn to_s(n: i64, b: i64) -> String {
  8. _to_s(String::new(), n, b, &"0123456789abcdefghijklmnopqrstuvwxyz".chars().collect())
  9. }
  10. fn main() {
  11. let mut line = String::new();
  12. if let Ok(_) = std::io::stdin().read_line(&mut line) {
  13. let strs = line.split_whitespace().collect::<Vec<&str>>();
  14. if let Ok(base) = strs[0].parse::<u32>() {
  15. if let Ok(n) = i64::from_str_radix(strs[1], base) {
  16. for b in 2..37 {
  17. println!("{}#{}", b, to_s(n, b));
  18. }
  19. }
  20. }
  21. }
  22. }
  23.  
Success #stdin #stdout 0s 4272KB
stdin
16 deadbabe
stdout
2#11011110101011011011101010111110
3#100122100210210001200
4#3132223123222332
5#30122344134421
6#1414413520330
7#161402600604
8#33653335276
9#10570723050
10#3735927486
11#1647919685
12#8831a30a6
13#476cc28a5
14#276253874
15#16ceb1726
16#deadbabe
17#91d36cc6
18#61f27270
19#437f24b8
20#2i79aie6
21#21bff6ii
22#1akk149g
23#125a42hj
24#jd49956
25#f7do8ob
26#c2b8boi
27#9h9ll1i
28#7l225hi
29#6842o9l
30#53m7kg6
31#46f9hir
32#3farelu
33#2tf7mor
34#2e7m366
35#214kbpb
36#1ps9w3i