L. Twice Equation ACM Nanning 2017

https://nanti.jisuanke.com/t/19978

 

acm提交:类 Main

使用java:高精度

BigInteger

 

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

public class Main {
    public static void main(String[] args)
    {
        BigInteger []f=new BigInteger[380];
        BigInteger v;
        int q,i;
        f[1]=BigInteger.valueOf(3);
        f[2]=BigInteger.valueOf(20);
        for (i=3;i<380;i++)
            f[i]=f[i-1].multiply(BigInteger.valueOf(6)).subtract(f[i-2]).add(BigInteger.valueOf(2));
        Scanner in=new Scanner(System.in);
        q=in.nextInt();
        while (q-->0)
        {
            v=in.nextBigInteger();
            for (i=1;i<380;i++)
                if (v.compareTo(f[i])<0)
                    break;
            System.out.println(f[i]);
                    
        }
    }
}

 

posted @ 2018-08-23 23:00  congmingyige  阅读(231)  评论(0编辑  收藏  举报