結果
| 問題 | 
                            No.44 DPなすごろく
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-12-03 20:57:07 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 50 ms / 5,000 ms | 
| コード長 | 4,112 bytes | 
| コンパイル時間 | 2,165 ms | 
| コンパイル使用メモリ | 80,040 KB | 
| 実行使用メモリ | 37,300 KB | 
| 最終ジャッジ日時 | 2024-07-06 04:26:39 | 
| 合計ジャッジ時間 | 4,106 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 20 | 
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
	static final int INF = 1000000000;
	static final long INFL = 1L << 60;
	static final long MOD = 1000000007;
	static final double EPS = 1e-10;
	static int dx[] = { 0, 0, 1, 1, 1, -1, -1, -1 };
	static int dy[] = { 1, -1, 1, 0, -1, 1, 0, -1 };
	static int H;
	static int W;
	static int A;
	static int B;
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		IO io = new IO();
		int N = io.getInt();
		long dp[] = new long[100];
		dp[0] = 1;
		for (int i = 0; i < N; i++) {
			dp[i + 1] += dp[i];
			dp[i + 2] += dp[i];
		}
		System.out.println(dp[N]);
	}
}
class Pair<T1 extends Comparable<? super T1>, T2 extends Comparable<? super T2>> implements Comparable<Pair<T1, T2>> {
	T1 first;
	T2 second;
	public Pair(T1 first, T2 second) {
		this.first = first;
		this.second = second;
	}
	@Override
	public int compareTo(Pair<T1, T2> other) {
		if (first.compareTo(other.first) != 0)
			return first.compareTo(other.first);
		else
			return second.compareTo(other.second);
	}
}
class IO {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public IO() {
	}
	public void println(String str) {
		System.out.println(str);
	}
	public void printArr(Object o[]) {
		for (int i = 0; i < o.length; i++) {
			System.out.print(o + " ");
		}
		System.out.println();
	}
	public int getInt() throws IOException {
		return Integer.parseInt(br.readLine());
	}
	public long getLong() throws IOException {
		return Long.parseLong(br.readLine());
	}
	public double getDouble() throws IOException {
		return Double.parseDouble(br.readLine());
	}
	public String getLine() throws IOException {
		return br.readLine();
	}
	public int[] getIntArrPrim() throws IOException {
		String str[] = br.readLine().split(" ");
		int a[] = new int[str.length];
		for (int i = 0; i < str.length; i++) {
			a[i] = Integer.parseInt(str[i]);
		}
		return a;
	}
	public Integer[] getIntArr() throws IOException {
		String str[] = br.readLine().split(" ");
		Integer a[] = new Integer[str.length];
		for (int i = 0; i < str.length; i++) {
			a[i] = Integer.parseInt(str[i]);
		}
		return a;
	}
	public Long[] getLongArr() throws IOException {
		String str[] = br.readLine().split(" ");
		Long a[] = new Long[str.length];
		for (int i = 0; i < str.length; i++) {
			a[i] = Long.parseLong(str[i]);
		}
		return a;
	}
	public long[] getLongArrPrim() throws IOException {
		String str[] = br.readLine().split(" ");
		long a[] = new long[str.length];
		for (int i = 0; i < str.length; i++) {
			a[i] = Long.parseLong(str[i]);
		}
		return a;
	}
	public String[] getStrArr(String split) throws IOException {
		return br.readLine().split(split);
	}
	public char[] getCharArr() throws IOException {
		return br.readLine().toCharArray();
	}
	public int[][] getIntMap(int w, int h, String split) throws IOException {
		int a[][] = new int[h][w];
		for (int i = 0; i < h; i++) {
			String str[] = br.readLine().split(split);
			for (int j = 0; j < w; j++) {
				a[i][j] = Integer.parseInt(str[j]);
			}
		}
		return a;
	}
	public long[][] getLongMap(int w, int h, String split) throws IOException {
		long a[][] = new long[h][w];
		for (int i = 0; i < h; i++) {
			String str[] = br.readLine().split(split);
			for (int j = 0; j < w; j++) {
				a[i][j] = Long.parseLong(str[j]);
			}
		}
		return a;
	}
	public double[][] getDoubleMap(int w, int h, String split) throws IOException {
		double a[][] = new double[h][w];
		for (int i = 0; i < h; i++) {
			String str[] = br.readLine().split(split);
			for (int j = 0; j < w; j++) {
				a[i][j] = Double.parseDouble(str[j]);
			}
		}
		return a;
	}
	public char[][] getCharMap(int w, int h, String split) throws IOException {
		char a[][] = new char[h][w];
		for (int i = 0; i < h; i++) {
			String str[] = br.readLine().split(split);
			for (int j = 0; j < w; j++) {
				a[i][j] = str[j].charAt(0);
			}
		}
		return a;
	}
}