Problem Source (Link)

I am kinda new with doing programming contests for myself.   I have been coaching a high school team for a 7 years now, but this is the first time I have come across this type of problem.   So it threw me off.

This problem is pretty simple.   One person picks the length of the word, and the other checks to see if you can find anything divisible by it.  No problem.  However, the number can be 100 digits long.   The variable type long cannot do that.   So I get out the Java class BigInteger.

So I quickly program this up:

import java.math.BigInteger;
import java.util.Scanner;

/*
 Kyle Dencker
 CodeForces #324 - Problem A
 October 6, 2015
 */
public class C324A {

    public static void main(String[] args) {
        Scanner scan =  new Scanner(System.in);
        
        int n = scan.nextInt();
        int t = scan.nextInt();
        
        BigInteger newT = new BigInteger(""+t);
        BigInteger digits = BigInteger.ONE;
        
        for (int i=1; i<n; i++) {
            digits = digits.multiply(BigInteger.TEN);
        }
        
        BigInteger stop = digits.multiply(BigInteger.TEN);
        
        for (;digits.compareTo(stop) < 0; digits = digits.add(BigInteger.ONE)) {
            if (digits.mod(newT).equals(BigInteger.ZERO)) {
                System.out.println(digits.toString());
                return;
            }
        }
        System.out.println(-1);

    }

}
C324A.java

What I would like you to focus on is I need to get the starting number.   If I use a 3 digit number, then 100 or 10^3 will be the lowest value.

I then just loop until I get to 1000 (999 as my last run through) and check to see if I can get a remainder of zero when dividing.   If I can, return that number.

However, what tricked me (I just decided to hey submit it and see what happens) is the test output could have quite a few correct answers.

However, all the pretests passed and I was excited to see that.   Then off to the next problem.