hihoCoder太阁最新面经算法竞赛19 register

Ended

Participants:128

Verdict:Accepted
Score:100 / 100
Submitted:2016-12-18 17:39:00

Lang:Java

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
    static Scanner I=new Scanner(System.in);
    public static void main(String[] args)
    {
        int N=I.nextInt();
        int[] ar = { 01234569121620273648648110814419225632443257676810241296172823043072409651846912921612288163842073627648368644915265536829441105921474561966082621443317764423685898247864321048576 };
        if(N<ar.length)System.out.println(ar[N]);
        else{
            int mod=(N-45)%5;int div=(N-45)/5;
            int w=ar[45+mod];
            
            BigInteger big=new BigInteger("4").modPow(new BigInteger(div+""), new BigInteger("1000000007"));
            big=big.multiply(new BigInteger(w+"")).mod(new BigInteger("1000000007"));
            System.out.println(big.toString());
        }
        I.close();
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX