Advertisement
Farjana_akter

Untitled

Aug 7th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. /*package whatever //do not write package name here */
  2.  
  3. import java.io.*;
  4. import java.math.BigInteger;
  5. import java.util.Scanner;
  6.  
  7.  
  8. class Main {
  9. public static void main (String[] args) {
  10. Scanner in=new Scanner(System.in);
  11. int a,b,t;
  12. while(in.hasNext())
  13. {
  14. t=in.nextInt();
  15. a=in.nextInt();
  16. b=in.nextInt();
  17. System.out.print("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) ");
  18. if(Math.log10(t)*(a-b)>=100 || t==1 || a<b || a%b!=0)
  19. System.out.println("is not an integer with less than 100 digits.");
  20. else if(b==a)
  21. System.out.println("1")
  22. else
  23. {
  24. BigInteger y,z,res;
  25. BigInteger x=BigInteger.valueOf(t);
  26. y=x.pow(a).subtract(BigInteger.ONE);
  27. z=x.pow(b).subtract(BigInteger.ONE);
  28. res=y.divide(z);
  29. if(res.toString().length()>=100)
  30. System.out.println("is not an integer with less than 100 digits.");
  31. else
  32. System.out.println(res);
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement