結果
| 問題 |
No.64 XORフィボナッチ数列
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-10 22:27:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 5,000 ms |
| コード長 | 1,242 bytes |
| コンパイル時間 | 1,819 ms |
| コンパイル使用メモリ | 107,264 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2024-10-10 22:27:16 |
| 合計ジャッジ時間 | 2,019 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = "InputX";
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));
}
//N番目の数列の値を求める
static ulong DeriveNthValue(ulong pF0, ulong pF1, ulong pN)
{
if (pN == 0) return pF0;
if (pN == 1) return pF1;
return pF0 ^ pF1;
}
}
aketijyuuzou