結果
問題 | No.954 Result |
ユーザー | RISE70226821 |
提出日時 | 2020-10-06 17:22:34 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 3,239 bytes |
コンパイル時間 | 2,602 ms |
コンパイル使用メモリ | 78,632 KB |
実行使用メモリ | 37,260 KB |
最終ジャッジ日時 | 2024-07-20 02:07:29 |
合計ジャッジ時間 | 5,721 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
37,040 KB |
testcase_01 | AC | 55 ms
36,676 KB |
testcase_02 | AC | 56 ms
37,108 KB |
testcase_03 | AC | 55 ms
37,192 KB |
testcase_04 | AC | 55 ms
36,980 KB |
testcase_05 | AC | 53 ms
36,980 KB |
testcase_06 | AC | 56 ms
37,092 KB |
testcase_07 | AC | 54 ms
36,920 KB |
testcase_08 | AC | 54 ms
37,260 KB |
testcase_09 | AC | 55 ms
36,932 KB |
testcase_10 | AC | 55 ms
37,164 KB |
testcase_11 | AC | 53 ms
36,944 KB |
testcase_12 | AC | 53 ms
36,960 KB |
testcase_13 | AC | 52 ms
36,924 KB |
testcase_14 | AC | 54 ms
36,932 KB |
testcase_15 | AC | 53 ms
36,972 KB |
testcase_16 | AC | 53 ms
37,236 KB |
testcase_17 | AC | 52 ms
37,028 KB |
testcase_18 | AC | 53 ms
37,208 KB |
testcase_19 | AC | 53 ms
37,056 KB |
testcase_20 | AC | 55 ms
36,928 KB |
testcase_21 | AC | 55 ms
37,088 KB |
testcase_22 | AC | 53 ms
37,048 KB |
testcase_23 | AC | 53 ms
36,956 KB |
testcase_24 | AC | 53 ms
36,908 KB |
testcase_25 | AC | 54 ms
36,924 KB |
testcase_26 | AC | 54 ms
37,036 KB |
testcase_27 | AC | 54 ms
37,048 KB |
testcase_28 | AC | 54 ms
36,772 KB |
testcase_29 | AC | 54 ms
37,196 KB |
testcase_30 | AC | 55 ms
37,048 KB |
testcase_31 | AC | 54 ms
36,908 KB |
testcase_32 | AC | 54 ms
37,048 KB |
testcase_33 | AC | 54 ms
37,100 KB |
testcase_34 | AC | 52 ms
37,088 KB |
testcase_35 | AC | 54 ms
36,796 KB |
ソースコード
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here // 入力 FastScanner sc = new FastScanner(System.in); long[] A = new long[5]; for(int i = 0; i < 5; i++){ A[i] = sc.nextLong(); } // フィボナッチ数列作成 long[] fibo = new long[100]; Arrays.fill(fibo,-1L); fibo[0] = 1L; fibo[1] = 1L; for(int i = 2; i < 100; i++){ fibo[i] = fibo[i-1] + fibo[i-2]; if(fibo[i] > 1000000000000000L){ break; } } // 判定 int count = 0; int startId = -1; long num = A[4]; for(int j = 0; j < 100; j++){ if(num == fibo[j]){ startId = j; count++; break; }else if(num < fibo[j]){ break; } } //System.out.println(startId); if(startId != -1){ int id = startId + 1; for(int i = 3; i >= 0; i--){ //System.out.println("A=" + A[i] + " fibo=" + fibo[id]); if(A[i] == fibo[id]){ count++; id++; }else{ break; } } } if(startId == 0){ startId = 1; int id = startId + 1; int count2 = 1; for(int i = 3; i >= 0; i--){ if(A[i] == fibo[id]){ count2++; id++; }else{ break; } } //System.out.println(count); //System.out.println(count2); if(count < count2){ count = count2; } } // 出力 System.out.println(count); } // 高速スキャナー static class FastScanner { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } } }