Submission #156186
Source Code Expand
package q2; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(System.in)); for (String line = br.readLine(); line != null; line = br.readLine()) { int n = Integer.parseInt(line); if (n == 1 || n == 2) { System.out.println(0); } else if (n == 3) { System.out.println(1); } else { // 愚直に求めます BigDecimal a1 = BigDecimal.ZERO; BigDecimal a2 = BigDecimal.ZERO; BigDecimal a3 = BigDecimal.valueOf(1); BigDecimal tri = BigDecimal.ZERO; for (int i = 0; i < n - 3; i++) { // 全部足したのがトリボナッチです tri = a1.add(a2).add(a3); // 1つずらします a1 = a2; a2 = a3; a3 = tri; } System.out.println(tri.remainder(BigDecimal.valueOf(10007))); } } } finally { if (br != null) { try { br.close(); } catch (IOException e) { } } } } }
Submission Info
Submission Time | |
---|---|
Task | A - 世界のFizzBuzz |
User | sugara99 |
Language | Java (OpenJDK 1.7.0) |
Score | 0 |
Code Size | 1182 Byte |
Status | RE |
Exec Time | 433 ms |
Memory | 20664 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | test_1.txt, test_2.txt, test_3.txt, test_4.txt, test_5.txt, test_6.txt, test_7.txt, test_8.txt, test_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | RE | 433 ms | 20664 KB |
sample_02.txt | RE | 402 ms | 20660 KB |
sample_03.txt | RE | 411 ms | 20628 KB |
test_1.txt | RE | 419 ms | 20660 KB |
test_2.txt | RE | 407 ms | 20660 KB |
test_3.txt | RE | 396 ms | 20660 KB |
test_4.txt | RE | 400 ms | 20584 KB |
test_5.txt | RE | 400 ms | 20660 KB |
test_6.txt | RE | 402 ms | 20664 KB |
test_7.txt | RE | 405 ms | 20656 KB |
test_8.txt | RE | 416 ms | 20628 KB |
test_9.txt | RE | 404 ms | 20652 KB |