Created
July 18, 2016 00:09
-
-
Save balamark/8a7740e1d4f9fb0dc5cfe07b7c8b919c to your computer and use it in GitHub Desktop.
brute force -> TLE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int getSmallest(int number, int k) { | |
String sn = String.valueOf(number); | |
BigInteger bi = new BigInteger(sn), bk = BigInteger.valueOf(k), z = BigInteger.ZERO; | |
//odd/even = -1 | |
if(number%2!=0 && k%2==0) return -1; | |
int c=1; | |
String s = sn; | |
while(bi.mod(bk)!=z){ | |
//extend | |
s += sn; | |
bi = new BigInteger(s); | |
c++; | |
} | |
return c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment