結果
問題 | No.533 Mysterious Stairs |
ユーザー | くれちー |
提出日時 | 2017-06-23 22:56:47 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 81 ms / 5,000 ms |
コード長 | 2,226 bytes |
コンパイル時間 | 1,240 ms |
コンパイル使用メモリ | 113,028 KB |
実行使用メモリ | 47,880 KB |
最終ジャッジ日時 | 2024-10-04 07:47:14 |
合計ジャッジ時間 | 2,918 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
#pragma warning disable IDE0011 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Numerics; class ReaderWriter { protected int _Index; protected string[] _Line; public void R(char sep = ' ') { _Line = Console.ReadLine().Split(sep); _Index = 0; } public string S() => _Line[_Index++]; public string[] Ss() => _Line.Skip(_Index++).ToArray(); public char C() => char.Parse(_Line[_Index++]); public char[] Cs() => _Line.Skip(_Index++).Select(char.Parse).ToArray(); public int I() => int.Parse(_Line[_Index++]); public int[] Is() => _Line.Skip(_Index++).Select(int.Parse).ToArray(); public long L() => long.Parse(_Line[_Index++]); public long[] Ls() => _Line.Skip(_Index++).Select(long.Parse).ToArray(); public double F() => double.Parse(_Line[_Index++]); public double[] Fs() => _Line.Skip(_Index++).Select(double.Parse).ToArray(); public decimal D() => decimal.Parse(_Line[_Index++]); public decimal[] Ds() => _Line.Skip(_Index++).Select(decimal.Parse).ToArray(); public BigInteger B() => BigInteger.Parse(_Line[_Index++]); public BigInteger[] Bs() => _Line.Skip(_Index++).Select(BigInteger.Parse).ToArray(); public void Write(params object[] xs) { Console.Write(xs.First()); foreach (var x in xs.Skip(1)) Console.Write(" " + x); Console.WriteLine(); } } class Program { static void Main() { Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }); Solve(new ReaderWriter()); Console.Out.Flush(); } static void Solve(ReaderWriter rw) { rw.R(); var n = rw.L(); const long mod = 1000000007; var dp = new long[1000001, 3]; dp[1, 0] = 1; dp[1, 1] = 0; dp[1, 2] = 0; dp[2, 0] = 0; dp[2, 1] = 1; dp[2, 2] = 0; dp[3, 0] = 1; dp[3, 1] = 1; dp[3, 2] = 1; for (var i = 4; i <= n; i++) { dp[i, 0] = (dp[i - 1, 1] + dp[i - 1, 2]) % mod; dp[i, 1] = (dp[i - 2, 0] + dp[i - 2, 2]) % mod; dp[i, 2] = (dp[i - 3, 0] + dp[i - 3, 1]) % mod; } rw.Write((dp[n, 0] + dp[n, 1] + dp[n, 2]) % mod); } }