結果
| 問題 |
No.526 フィボナッチ数列の第N項をMで割った余りを求める
|
| コンテスト | |
| ユーザー |
cedretaber
|
| 提出日時 | 2020-03-27 02:21:01 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 347 bytes |
| コンパイル時間 | 689 ms |
| コンパイル使用メモリ | 104,656 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 05:48:23 |
| 合計ジャッジ時間 | 1,795 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;
void main()
{
auto nm = readln.split.to!(long[]);
auto N = nm[0];
auto M = nm[1];
long f1 = 0;
long f2 = 1;
foreach (_; 2..N) {
auto f3 = (f1 + f2) % M;
f1 = f2;
f2 = f3;
}
writeln(f2);
}
cedretaber