結果

問題 No.3036 Restricted Lucas (Easy)
ユーザー claw88claw88
提出日時 2018-04-02 00:16:39
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,964 bytes
コンパイル時間 4,314 ms
コンパイル使用メモリ 103,084 KB
実行使用メモリ 23,200 KB
最終ジャッジ日時 2023-09-08 13:08:23
合計ジャッジ時間 5,560 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 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.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;
using static System.Decimal;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();


    Dictionary<int, decimal> L;
    int zero, one, two, three, seven, ten; decimal h, m, mod;
    void solve()
    {
        L = new Dictionary<int, decimal>();
        one++;
        two = one + one;
        three = one + two;
        seven = three + two + two;
        ten = seven + three;
        h = Multiply(ten, ten);
        m = Multiply(h, h);
        mod = Add(Multiply(Multiply(m, m), ten), seven);
        WriteLine(mod);

        L[zero] = two;
        L[one] = one;
        L[two] = three;


        int T = cin.scanint[zero];
        for (int i = zero; i < T; i++)
        {
            WriteLine(calc(cin.scanint[zero]));
        }

    }
    decimal calc(int X)
    {
        if (L.ContainsKey(X)) return L[X];

        Math.DivRem(X, two, out long r);
        if (r == zero)
        {
            var t = decimal.Multiply(calc(X >> one), calc(X >> one));
            Math.DivRem(X >> one, two, out r);
            if (r == one)
            {
                t += two;
            }
            else
            {
                t -= two;
            }
            return L[X] = Remainder(t, mod);
        }
        else
        {
            var t = calc(X + one) - calc(X - one) + mod;
            return L[X] = Remainder(t, mod);
        }

    }

}

class Scanner
{
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
}
0