Cod sursa(job #1749048)

Utilizator raduta_vladVlad Raduta raduta_vlad Data 27 august 2016 19:09:36
Problema Parcurgere DFS - componente conexe Scor 0
Compilator java Status done
Runda Arhiva educationala Marime 0.71 kb
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner( new File("date.in") );
        BigInteger t1 = BigInteger.valueOf(in.nextInt());
        BigInteger t2 = BigInteger.valueOf(in.nextInt());
        int n =in.nextInt();
        BigInteger sol = fiboMod(t1, t2, n);
        
        System.out.print(sol);
    }
    
   public static BigInteger fiboMod(BigInteger t1,BigInteger t2,int n){
        n = n-1;
        if(n == 1){
            return t2;
        }
        return fiboMod(t2,t2.pow(2).add(t1),n);
    }
}