3602. Hexadecimal and Hexatrigesimal Conversion Easy
1/**
2 * [3602] Hexadecimal and Hexatrigesimal Conversion
3 *
4 * You are given an integer n.
5 * Return the concatenation of the hexadecimal representation of n^2 and the hexatrigesimal representation of n^3.
6 * A hexadecimal number is defined as a base-16 numeral system that uses the digits 0 – 9 and the uppercase letters A - F to represent values from 0 to 15.
7 * A hexatrigesimal number is defined as a base-36 numeral system that uses the digits 0 – 9 and the uppercase letters A - Z to represent values from 0 to 35.
8 *
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">n = 13</span>
12 * Output: <span class="example-io">"A91P1"</span>
13 * Explanation:
14 *
15 * n^2 = 13 * 13 = 169. In hexadecimal, it converts to (10 * 16) + 9 = 169, which corresponds to "A9".
16 * n^3 = 13 * 13 * 13 = 2197. In hexatrigesimal, it converts to (1 * 36^2) + (25 * 36) + 1 = 2197, which corresponds to "1P1".
17 * Concatenating both results gives "A9" + "1P1" = "A91P1".
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">n = 36</span>
22 * Output: <span class="example-io">"5101000"</span>
23 * Explanation:
24 *
25 * n^2 = 36 * 36 = 1296. In hexadecimal, it converts to (5 * 16^2) + (1 * 16) + 0 = 1296, which corresponds to "510".
26 * n^3 = 36 * 36 * 36 = 46656. In hexatrigesimal, it converts to (1 * 36^3) + (0 * 36^2) + (0 * 36) + 0 = 46656, which corresponds to "1000".
27 * Concatenating both results gives "510" + "1000" = "5101000".
28 * </div>
29 *
30 * Constraints:
31 *
32 * 1 <= n <= 1000
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/hexadecimal-and-hexatrigesimal-conversion/
38// discuss: https://leetcode.com/problems/hexadecimal-and-hexatrigesimal-conversion/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn concat_hex36(n: i32) -> String {
44 String::new()
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3602() {
56 }
57}
58Back
© 2026 bowen.ge All Rights Reserved.