Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*package whatever //do not write package name here */
- import java.io.*;
- import java.math.BigInteger;
- import java.util.Scanner;
- class Main {
- public static void main (String[] args) {
- Scanner in=new Scanner(System.in);
- int a,b,t;
- while(in.hasNext())
- {
- t=in.nextInt();
- a=in.nextInt();
- b=in.nextInt();
- System.out.print("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) ");
- if(Math.log10(t)*(a-b)>=100 || t==1 || a<b || a%b!=0)
- System.out.println("is not an integer with less than 100 digits.");
- else if(b==a)
- System.out.println("1")
- else
- {
- BigInteger y,z,res;
- BigInteger x=BigInteger.valueOf(t);
- y=x.pow(a).subtract(BigInteger.ONE);
- z=x.pow(b).subtract(BigInteger.ONE);
- res=y.divide(z);
- if(res.toString().length()>=100)
- System.out.println("is not an integer with less than 100 digits.");
- else
- System.out.println(res);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement