java.math.BigDecimal Import; Import java.util.Scanner; Import java.util.function.BinaryOperator; public class Fbnq { / ** * Let n be a positive integer, Fibonacci number is defined as: * F (n) . 1 =, n-<. 3; * f (n) = F (n--. 1) + F (n--2), n-> =. 3 * * now you to calculate the value f (n), but need not be given exact values, as long as the results after six. * * Input: line, contains a positive integer n, and 0 <n-<1000 * output: one line after the f (n) of the six (decimal, zero padding is not less than 6) * @param args * / public static void main (String [] args) { Scanner Scanner new new = S (the System.in); int I = s.nextInt (); the BigDecimal F2 = FB (I); String String.valueOf V = (F2); IF (V. length ()> 6) { String substring = v.substring(v.length() - 6); System.out.println(substring); }else { System.out.println(v); } } static BigDecimal fb(int num){ BigDecimal m = new BigDecimal(1); BigDecimal n = new BigDecimal(1); if (num == 1 || num == 2){ return m; } BigDecimal t = new BigDecimal(0); for (int i = 0; i <= num-3; i++) { t = m.add(n); m = n; n = t; } return t; } /*public static int fb1(int num) { if (num == 1 || whether == 2) { return 1; } else { return fB1 (num - 1) + fB1 (whether - 2); } } * / }