結果

問題 No.510 二次漸化式
ユーザー masaktmasakt
提出日時 2017-04-29 00:18:42
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,704 bytes
コンパイル時間 4,527 ms
コンパイル使用メモリ 103,652 KB
実行使用メモリ 29,356 KB
最終ジャッジ日時 2023-10-11 20:49:01
合計ジャッジ時間 34,526 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 TLE -
testcase_17 WA -
testcase_18 TLE -
testcase_19 WA -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int q = int.Parse(Console.ReadLine());
            long[] x = new long[n + 1];
            long[] y = new long[n + 1];
            long[] a = new long[n + 1];
            long[] b = new long[n + 1];
            a[0] = b[0] = 1;
            int sx = 0;
            int sy = 0;

            string[] query = new string[3];
            for (int i = 0; i < q; i++)
            {
                query = Console.ReadLine().Split(' ');
                if (query[0] == "x")
                {
                    x[int.Parse(query[1])] = int.Parse(query[2]);
                    sx = Math.Min(sx, int.Parse(query[1]));
                }
                else if (query[0] == "y")
                {
                    y[int.Parse(query[1])] = int.Parse(query[2]);
                    sy = Math.Min(sy, int.Parse(query[1]));
                }
                else
                {
                    int l = int.Parse(query[1]);
                    for (int j = 0; j < l; j++)
                    {
                        if (sx - 1 <= j)
                        {
                            a[j + 1] = (x[j] * b[j] % 1000000007L * b[j] + a[j]) % 1000000007L;
                            sx++;
                        }
                        if (sy - 1 <= j)
                        {
                            b[j + 1] = (y[j] * b[j] + 1) % 1000000007L;
                            sy++;
                        }
                    }
                    Console.WriteLine(a[l]);
                }
            }
        }
    }
}
0