package uvaTry;
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;
class Main10083 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BigInteger tem1;
int a,b,t;
Scanner sc=new Scanner(System.in);
while(sc.hasNext())
{
t=sc.nextInt();
a=sc.nextInt();
b=sc.nextInt();
if(t==1)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");
continue;
}
if(a==b)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) 1");
continue;
}
if(a%b!=0||a<b)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");
continue;
}
if( (a - b) * Math.log10(t) > 99)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");
continue;
}
tem1=((BigInteger.valueOf(t)).pow(a)).subtract(BigInteger.ONE).divide(((BigInteger.valueOf(t)).pow(b)).subtract(BigInteger.ONE));
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) "+tem1);
}
}
}
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;
class Main10083 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BigInteger tem1;
int a,b,t;
Scanner sc=new Scanner(System.in);
while(sc.hasNext())
{
t=sc.nextInt();
a=sc.nextInt();
b=sc.nextInt();
if(t==1)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");
continue;
}
if(a==b)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) 1");
continue;
}
if(a%b!=0||a<b)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");
continue;
}
if( (a - b) * Math.log10(t) > 99)
{
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) is not an integer with less than 100 digits.");
continue;
}
tem1=((BigInteger.valueOf(t)).pow(a)).subtract(BigInteger.ONE).divide(((BigInteger.valueOf(t)).pow(b)).subtract(BigInteger.ONE));
System.out.println("("+t+"^"+a+"-1)/("+t+"^"+b+"-1) "+tem1);
}
}
}
0 comments :
Post a Comment