結果
| 問題 | 
                            No.64 XORフィボナッチ数列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             明智重蔵
                         | 
                    
| 提出日時 | 2015-08-04 22:10:51 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 30 ms / 5,000 ms | 
| コード長 | 1,539 bytes | 
| コンパイル時間 | 908 ms | 
| コンパイル使用メモリ | 119,332 KB | 
| 実行使用メモリ | 27,156 KB | 
| 最終ジャッジ日時 | 2024-07-18 01:19:49 | 
| 合計ジャッジ時間 | 1,962 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 11 | 
コンパイルメッセージ
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;
    }
}
            
            
            
        
            
明智重蔵