結果
問題 | No.64 XORフィボナッチ数列 |
ユーザー | 明智重蔵 |
提出日時 | 2015-08-04 22:10:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 62 ms / 5,000 ms |
コード長 | 1,539 bytes |
コンパイル時間 | 2,351 ms |
コンパイル使用メモリ | 107,736 KB |
実行使用メモリ | 23,956 KB |
最終ジャッジ日時 | 2023-09-25 01:09:34 |
合計ジャッジ時間 | 4,124 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
21,844 KB |
testcase_01 | AC | 62 ms
23,956 KB |
testcase_02 | AC | 61 ms
23,860 KB |
testcase_03 | AC | 61 ms
21,912 KB |
testcase_04 | AC | 62 ms
23,820 KB |
testcase_05 | AC | 62 ms
21,848 KB |
testcase_06 | AC | 62 ms
21,892 KB |
testcase_07 | AC | 62 ms
23,880 KB |
testcase_08 | AC | 61 ms
19,796 KB |
testcase_09 | AC | 62 ms
23,876 KB |
testcase_10 | AC | 61 ms
21,776 KB |
testcase_11 | AC | 61 ms
23,876 KB |
testcase_12 | AC | 60 ms
21,872 KB |
testcase_13 | AC | 61 ms
21,836 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "Input4"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("88 79 2"); //23 } else if (InputPattern == "Input2") { WillReturn.Add("88 79 0"); //88 } else if (InputPattern == "Input3") { WillReturn.Add("88 79 82"); //79 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); ulong[] wkArr = InputList[0].Split(' ').Select(X => ulong.Parse(X)).ToArray(); ulong F0 = wkArr[0]; ulong F1 = wkArr[1]; ulong N = wkArr[2]; Console.WriteLine(DeriveNthValue(F0, F1, N % 3)); //前2つのビットが00なら0が無限に循環する //前2つのビットが01なら011011と循環する //前2つのビットが10なら101101と循環する //前2つのビットが11なら110110と循環する //よって3つ周期で循環する } //N番目の数列の値を求める static ulong DeriveNthValue(ulong pF0, ulong pF1, ulong pN) { if (pN == 0) return pF0; if (pN == 1) return pF1; return pF0 ^ pF1; } }