Last active
July 17, 2016 14:08
-
-
Save Jack-Saleem/935b7e55cda48fec7e7c808b95a19443 to your computer and use it in GitHub Desktop.
codeforces 614A LinkOrCutTree program in java
This file contains 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
import java.math.BigInteger; | |
import java.util.Scanner; | |
public class LinkOrCutTree | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner z=new Scanner(System.in); | |
BigInteger bl=new BigInteger(z.next()); | |
BigInteger br=new BigInteger(z.next()); | |
BigInteger bk=new BigInteger(z.next()); | |
int i=0; | |
BigInteger ba; | |
String x=""; | |
while(true) | |
{ | |
ba=bk.pow(i); | |
if(ba.compareTo(br)==1) | |
break; | |
if((ba.compareTo(bl)==0 || ba.compareTo(bl)==1) && (ba.compareTo(br)==0 || ba.compareTo(br)==-1)) | |
x+=ba+" "; | |
i++; | |
} | |
if(x.length()/2==0) | |
System.out.println("-1"); | |
else | |
System.out.println(x.trim()); | |
z.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment