結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー qwrtpsfgqwrtpsfg
提出日時 2017-10-17 18:26:52
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 535 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 106,496 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-29 00:43:18
合計ジャッジ時間 2,036 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
19,200 KB
testcase_01 AC 27 ms
19,072 KB
testcase_02 AC 26 ms
19,072 KB
testcase_03 AC 27 ms
19,200 KB
testcase_04 AC 27 ms
19,072 KB
testcase_05 AC 26 ms
18,816 KB
testcase_06 WA -
testcase_07 AC 26 ms
18,816 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Collections.Generic;

public class yukicoder
{

	public static long fib(long n)
	{
		if(n <= 1)
			return n;
			
		long fib1 = 0;
		long fib2 = 1;
		long temp;
		
		for(int i = 2; i <= n; i++)
		{
			temp = fib1 + fib2;
			fib1 = fib2;
			fib2 = temp;
		}
		
		return fib2;
	}

    public static void Main()
    {
		long[] input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
		long a = input[0];
		long b = input[1];
		
		Console.WriteLine(fib(a - 1) % b);
    }
}
0