結果

問題 No.510 二次漸化式
ユーザー masakt
提出日時 2017-04-29 00:05:36
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,504 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 107,936 KB
実行使用メモリ 23,296 KB
最終ジャッジ日時 2024-09-13 18:48:41
合計ジャッジ時間 7,949 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 TLE * 1 -- * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Text;
using System.Threading.Tasks;

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;

            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]);
                }
                else if (query[0] == "y")
                {
                    y[int.Parse(query[1])] = int.Parse(query[2]);
                }
                else
                {
                    int l = int.Parse(query[1]);
                    for (int j = 0; j < l; j++)
                    {
                        a[j + 1] = ((x[j] * b[j] % 1000000007L) * b[j] % 1000000007L + a[j]) % 1000000007L;
                        a[j + 1] %= 1000000007L;
                        b[j + 1] = (y[j] * b[j] % 1000000007L + 1) % 1000000007L;
                        b[j + 1] %= 1000000007L;
                    }
                    Console.WriteLine(a[l]);
                }
            }
        }
    }
}
0