結果
問題 | No.44 DPなすごろく |
ユーザー | threepipes_s |
提出日時 | 2014-11-25 00:51:03 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 2,593 bytes |
コンパイル時間 | 2,870 ms |
コンパイル使用メモリ | 75,076 KB |
実行使用メモリ | 49,724 KB |
最終ジャッジ日時 | 2023-08-30 22:46:45 |
合計ジャッジ時間 | 4,353 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,532 KB |
testcase_01 | AC | 44 ms
49,444 KB |
testcase_02 | AC | 42 ms
49,608 KB |
testcase_03 | AC | 43 ms
49,504 KB |
testcase_04 | AC | 44 ms
49,564 KB |
testcase_05 | AC | 43 ms
49,724 KB |
testcase_06 | AC | 42 ms
49,588 KB |
testcase_07 | AC | 42 ms
49,704 KB |
testcase_08 | AC | 43 ms
49,692 KB |
testcase_09 | AC | 42 ms
49,672 KB |
testcase_10 | AC | 42 ms
49,568 KB |
testcase_11 | AC | 43 ms
47,488 KB |
testcase_12 | AC | 42 ms
49,672 KB |
testcase_13 | AC | 42 ms
49,588 KB |
testcase_14 | AC | 42 ms
49,328 KB |
testcase_15 | AC | 44 ms
49,720 KB |
testcase_16 | AC | 43 ms
49,656 KB |
testcase_17 | AC | 41 ms
49,684 KB |
testcase_18 | AC | 43 ms
49,704 KB |
testcase_19 | AC | 44 ms
49,544 KB |
testcase_20 | AC | 43 ms
49,700 KB |
testcase_21 | AC | 43 ms
49,700 KB |
testcase_22 | AC | 44 ms
49,716 KB |
testcase_23 | AC | 43 ms
49,604 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()); } }