Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.math.BigInteger;
- import java.util.Scanner;
- public class dpF {
- public static void main(String[] args) throws FileNotFoundException {
- Scanner in = new Scanner(new File("input.txt"));
- PrintWriter out = new PrintWriter(new File("output.txt"));
- int N = in.nextInt();
- BigInteger[] kol = new BigInteger[N+2];
- kol[0] = BigInteger.ONE;
- kol[1] = BigInteger.ONE;
- for (int i = 2; i <=N+1 ; i++) {
- kol[i] = new BigInteger("0");
- kol[i] = kol[i].add(kol[i-1]);
- kol[i] = kol[i].add(kol[i-2]);
- }
- out.println(kol[N+1]);
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement