Submission #3791811
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(in, out); out.close(); } static class Task { void solve(InputReader in, PrintWriter out) { int N = in.nextInt(); long[] lucas = new long[N + 1]; lucas[0] = 2; lucas[1] = 1; for (int i = 2; i < N + 1; i++) { lucas[i] = lucas[i - 1] + lucas[i - 2]; } out.println(lucas[N]); } } static class InputReader { BufferedReader reader; StringTokenizer tokenizer; InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } int nextInt() { return Integer.parseInt(next()); } } }
Submission Info
Submission Time | |
---|---|
Task | B - Lucas Number |
User | hatsujime |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 1706 Byte |
Status | AC |
Exec Time | 74 ms |
Memory | 23380 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, sample_01.txt, sample_02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 73 ms | 20564 KB |
02.txt | AC | 73 ms | 20688 KB |
03.txt | AC | 73 ms | 20820 KB |
04.txt | AC | 74 ms | 20692 KB |
05.txt | AC | 71 ms | 21332 KB |
06.txt | AC | 71 ms | 18772 KB |
07.txt | AC | 72 ms | 17236 KB |
08.txt | AC | 71 ms | 18516 KB |
09.txt | AC | 72 ms | 18900 KB |
10.txt | AC | 74 ms | 20820 KB |
11.txt | AC | 73 ms | 20692 KB |
12.txt | AC | 71 ms | 19028 KB |
13.txt | AC | 70 ms | 17748 KB |
14.txt | AC | 71 ms | 23124 KB |
sample_01.txt | AC | 72 ms | 23380 KB |
sample_02.txt | AC | 71 ms | 18772 KB |