結果
問題 | No.44 DPなすごろく |
ユーザー | threepipes_s |
提出日時 | 2014-11-25 00:51:03 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 57 ms / 5,000 ms |
コード長 | 2,593 bytes |
コンパイル時間 | 2,643 ms |
コンパイル使用メモリ | 78,136 KB |
実行使用メモリ | 50,456 KB |
最終ジャッジ日時 | 2024-06-10 22:06:36 |
合計ジャッジ時間 | 4,332 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
50,052 KB |
testcase_01 | AC | 53 ms
50,060 KB |
testcase_02 | AC | 54 ms
49,900 KB |
testcase_03 | AC | 53 ms
50,100 KB |
testcase_04 | AC | 52 ms
50,292 KB |
testcase_05 | AC | 53 ms
50,456 KB |
testcase_06 | AC | 55 ms
50,396 KB |
testcase_07 | AC | 53 ms
50,324 KB |
testcase_08 | AC | 52 ms
50,036 KB |
testcase_09 | AC | 53 ms
50,396 KB |
testcase_10 | AC | 54 ms
50,432 KB |
testcase_11 | AC | 54 ms
50,112 KB |
testcase_12 | AC | 52 ms
50,328 KB |
testcase_13 | AC | 54 ms
49,976 KB |
testcase_14 | AC | 52 ms
50,356 KB |
testcase_15 | AC | 54 ms
50,428 KB |
testcase_16 | AC | 54 ms
49,984 KB |
testcase_17 | AC | 56 ms
50,056 KB |
testcase_18 | AC | 53 ms
49,912 KB |
testcase_19 | AC | 54 ms
49,924 KB |
testcase_20 | AC | 57 ms
50,144 KB |
testcase_21 | AC | 56 ms
50,228 KB |
testcase_22 | AC | 54 ms
50,156 KB |
testcase_23 | AC | 54 ms
50,424 KB |
ソースコード
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.TreeSet; public class Main { public static int w; public static int k; public static int n; // public static int[][] dp; public static int[] a; public static int[] b; public static List<double[]> list = new ArrayList<double[]>(); public static TreeSet<Integer> set = new TreeSet<Integer>(); // public static PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); public static void main(String[] args) throws NumberFormatException, IOException{ ContestScanner in = new ContestScanner(); n = in.nextInt(); long[] dp = new long[n+1]; dp[0] = 1; dp[1] = 1; for(int i=2; i<=n; i++){ dp[i] = dp[i-1] + dp[i-2]; } System.out.println(dp[n]); } } class Node{ int id; List<Node> edge = new ArrayList<Node>(); public Node(int id){ this.id = id; } public void createEdge(Node node){ edge.add(node); } } class MyMath{ public static long fact(long n){ long res = 1; while(n > 0){ res *= n--; } return res; } public static long[][] pascalT(int n){ long[][] tri = new long[n][]; for(int i=0; i<n; i++){ tri[i] = new long[i+1]; for(int j=0; j<i+1; j++){ if(j == 0 || j == i){ tri[i][j] = 1; }else{ tri[i][j] = tri[i-1][j-1] + tri[i-1][j]; } } } return tri; } } class MyComp implements Comparator<Integer>{ public int compare(Integer arg0, Integer arg1) { return arg0 - arg1; } } // //class MyCompB implements Comparator<int[]>{ // public int compare(int[] arg0, int[] arg1) { // return arg0[1] - arg1[1]; // } //} class ContestScanner{ private BufferedReader reader; private String[] line; private int idx; public ContestScanner() throws FileNotFoundException{ reader = new BufferedReader(new InputStreamReader(System.in)); } public String nextToken() throws IOException{ if(line == null || line.length <= idx){ line = reader.readLine().trim().split(" "); idx = 0; } return line[idx++]; } public long nextLong() throws IOException, NumberFormatException{ return Long.parseLong(nextToken()); } public int nextInt() throws NumberFormatException, IOException{ return (int)nextLong(); } public double nextDouble() throws NumberFormatException, IOException{ return Double.parseDouble(nextToken()); } }