# 数学-高精度

1.Integer Inquiry

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] arg)
{
Scanner in=new Scanner(System.in);
int t;
while(in.hasNext())
{
t=in.nextInt();
while(t-->0)
{
BigInteger b=new BigInteger("0");
while(in.hasNextBigInteger())
{
BigInteger c=new BigInteger("0");
c=in.nextBigInteger();
if(!c.equals(BigInteger.ZERO))
{
}
else
{
System.out.println(b);
if(t!=0)
System.out.println();
break;
}
}
}
}
}
}

2.Exponentiation

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
public static void main(String[] arg)
{
Scanner in=new Scanner(System.in);
while(in.hasNext())
{
BigDecimal a=in.nextBigDecimal();
int k=in.nextInt();
a=a.pow(k);
String str=a.stripTrailingZeros().toPlainString();
if(str.charAt(0)=='0')
System.out.println(str.substring(1));
else
System.out.println(str);
}
}
}

3.How many Fibs?

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
static BigInteger a[]=new BigInteger[10000];
public static void main(String[] arg)
{
Scanner in=new Scanner(System.in);
for(int i=0;i<10000;i++)
a[i]=BigInteger.ZERO;
a[0]=BigInteger.valueOf(1);
a[1]=BigInteger.valueOf(2);
for(int i=2;i<10000;i++)
BigInteger b,c;
while(true)
{
b=in.nextBigInteger();
c=in.nextBigInteger();
if(b.equals(BigInteger.ZERO)&&c.equals(BigInteger.ZERO))
break;
int res=0;
for(int i=0;i<10000;i++)
{
if((a[i].compareTo(b)==1||a[i].compareTo(b)==0)&&(a[i].compareTo(c)==-1||a[i].compareTo(c)==0))
res++;
if(a[i].compareTo(c)==1)
break;
}
System.out.println(res);
}
}
}

4.Segment

import java.math.BigInteger;
import java.util.Scanner;

public class Main{
public static void main(String[] arg)
{
Scanner in=new Scanner(System.in);
int T=in.nextInt();
while(T-->0)
{
BigInteger q=in.nextBigInteger();
BigInteger p=in.nextBigInteger();
BigInteger f=q.subtract(BigInteger.valueOf(2));
BigInteger res=q.subtract(BigInteger.ONE).multiply(f).divide(BigInteger.valueOf(2));
res=res.mod(p);
System.out.println(res);
}
}
}

5.Problem B

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
public static void main(String[] arg)
{
Scanner in=new Scanner(System.in);
BigInteger a[]=new BigInteger[10000];
for(int i=0;i<10000;i++)
a[i]=BigInteger.ZERO;
a[0]=BigInteger.valueOf(1);
a[1]=BigInteger.valueOf(1);
for(int i=2;i<10000;i++)
}