結果

問題 No.64 XORフィボナッチ数列
ユーザー mbanmban
提出日時 2016-10-12 17:40:24
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 838 ms
コンパイル使用メモリ 112,372 KB
実行使用メモリ 27,268 KB
最終ジャッジ日時 2024-05-01 19:19:50
合計ジャッジ時間 1,780 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
25,152 KB
testcase_01 AC 25 ms
25,028 KB
testcase_02 AC 24 ms
25,344 KB
testcase_03 AC 24 ms
25,136 KB
testcase_04 AC 24 ms
27,016 KB
testcase_05 RE -
testcase_06 AC 23 ms
24,968 KB
testcase_07 AC 24 ms
27,000 KB
testcase_08 RE -
testcase_09 AC 23 ms
25,284 KB
testcase_10 AC 24 ms
25,220 KB
testcase_11 AC 24 ms
23,348 KB
testcase_12 AC 24 ms
27,268 KB
testcase_13 AC 23 ms
24,896 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
    static void Main()
    {
        long[] N = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        if (N[2] % 3 == 0)
        {
            Console.WriteLine(N[0]);
        }
        else if (N[2] % 3 == 1)
        {
            Console.WriteLine(N[1]);
        }
        else
        {
            string a = Convert.ToString(N[0], 2);
            string b = Convert.ToString(N[1], 2);
            int l = Math.Max(a.Length, b.Length);
            string f = string.Format("0:D{0}", l);
            a = string.Format("{"+ f+"}", a);
            b = string.Format("{"+f+"}", b);
            string c = "";
            for(int i = 0; i < l; i++)
            {
                if (a[i] == '1' ^ b[i] == '1')
                {
                    c += "1";
                }
                else
                {
                    c += "0";
                }
            }
            Console.Write(Convert.ToInt64(c,2));
        }

       

    }

}


0