Problem:
Score : 100 points

Problem Statement

Decades have passed since the beginning of AtCoder Beginner Contest.

The contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled?

In the end, the labels for the rounds from the 1000-th to the 1998-th are decided: ABD001, ABD002, ..., ABD999.

You are given an integer N between 1 and 1998 (inclusive). Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.

Constraints

1 \leq N \leq 1998

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the first three characters of the label of the N-th round of AtCoder Beginner Contest.

Sample Input 1

999

Sample Output 1

ABC

The 999-th round of AtCoder Beginner Contest is labeled as ABC999.

Sample Input 2

1000

Sample Output 2

ABD

The 1000-th round of AtCoder Beginner Contest is labeled as ABD001.

Sample Input 3

1481

Sample Output 3

ABD

The 1481-th round of AtCoder Beginner Contest is labeled as ABD482.

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)


import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int N=scanner.nextInt();
        final int NN=100001;
        int[] count=new int[NN];
        int[] sample={0,1,2,3,4,5,1,2,3,1};
        for(int i=0;i<sample.length;i++){
            count[i]=sample[i];
        }
        for(int i=sample.length;i<NN;i++){
            int minNum=Integer.MAX_VALUE;
            int j=0;
            while(i>=Math.pow(6,j)){
                if(minNum>count[i-(int)Math.pow(6,j)]){
                    minNum=count[i-(int)Math.pow(6,j)]+1;
                }
                j++;
            }
            j=0;
            while(i>=Math.pow(9,j)){
                if(minNum>count[i-(int)Math.pow(9,j)]){
                    minNum=count[i-(int)Math.pow(9,j)]+1;
                }
                j++;
            }
            count[i]=minNum;
        }
        System.out.println(count[N]);

    }
}