fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.*;
  7. import java.util.Scanner;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. public class Main
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. BigInteger bi1,bi2,bi3,bi4;
  15. int x,i,l,r,v,ll,rr,ans;
  16. ans=0;
  17. Scanner sc = new Scanner(System.in);
  18. l=sc.nextInt();
  19. r=sc.nextInt();
  20. x=sc.nextInt();
  21. bi2=BigInteger.valueOf(l);
  22. bi3=BigInteger.valueOf(r);
  23. bi4=BigInteger.valueOf(x);
  24. bi1=BigInteger.valueOf(1);
  25. i=1;
  26. while(i<r)
  27. {
  28. i++;
  29. ll=bi1.compareTo(bi2);
  30. rr=bi1.compareTo(bi3);
  31. if(ll>=0&&rr<=0)
  32. {
  33. ans++;
  34. System.out.print(bi1.toString()+" ");
  35. }
  36. bi1=bi1.multiply(bi4);
  37.  
  38. }
  39. if(ans==0){System.out.println(-1);}
  40. }
  41. }
Runtime error #stdin #stdout #stderr 0.14s 321280KB
stdin
1 1000000000000000000 1000000000
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.InputMismatchException: For input string: "1000000000000000000"
	at java.util.Scanner.nextInt(Scanner.java:2123)
	at java.util.Scanner.nextInt(Scanner.java:2076)
	at Main.main(Main.java:19)