// Add imports as needed
import java.util.Scanner;
import java.math.BigInteger;
public class Main
{
public static void main(String[] args)
{
final Scanner cin = new Scanner(System.in);
BigInteger []a1 = new BigInteger[5555];
while(cin.hasNextInt())
{
int n = cin.nextInt();
if(n>=1||n<=5555) {
System.out.println(CountTn(n,a1));
}
else
System.err.println();
}
}
public static BigInteger CountTn(int n,BigInteger []array){
if(array[n-1]!=null){
return array[n-1];
}
else{
if(n<=10){
array[n-1] = new BigInteger("1");
return array[n-1];
}
else {
BigInteger b1 = CountTn(n-1,array);
BigInteger b2 = CountTn((int)n/2,array).multiply(new BigInteger("3"));
BigInteger b3 = b1.add(b2).add(new BigInteger("1"));
array[n-1] = b3;
return b3;
}
}
}
// Add other methods and data members as needed
}
3.14 Lab: Recurrence Evaluation
最新推荐文章于 2024-09-09 09:51:11 发布