結果

問題 No.492 IOI数列
ユーザー 14番14番
提出日時 2017-03-11 00:19:05
言語 C#(csc)
(csc 3.9.0)
結果
MLE  
実行時間 -
コード長 2,102 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 106,200 KB
実行使用メモリ 793,260 KB
最終ジャッジ日時 2023-09-06 14:51:20
合計ジャッジ時間 5,226 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
25,268 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Text;
 
public class Program
{
    public void Proc() {
        Reader.IsDebug = false;
        decimal num = decimal.Parse(Reader.ReadLine());

        Console.WriteLine(GetMod(1, num-1));
        decimal ans = 0;
        if(num%11>0) {
            ans = Get101Num(1, (int)(num%11)-1);
        }
        Console.WriteLine(ans);

    }

    private decimal Get101Num(decimal num, int keta) {
        if(keta == 0) {
            return num;
        }
        decimal tmp = num;
        for(int i=1; i<=keta; i++) {
            tmp = tmp * 100 + 1;
        }
        return tmp;
    }

    Dictionary<decimal, decimal> dic = new Dictionary<decimal, decimal>();
    private decimal GetMod(decimal num, decimal remain) {
        if(remain <= 5) {
            decimal num2 = Get101Num(num, (int)remain);
            return num2%mod1;
        }
        if(!dic.ContainsKey(num)) {
            dic.Add(num,remain);
        } else {
            decimal tmp = dic[num] - remain;
            decimal newRemain = remain % tmp;
            if(newRemain != remain) {
                return this.GetMod(num, newRemain);
            }
        }
        
        decimal target = Get101Num(num, (int)Math.Min(remain, 5));
        decimal newR = remain - Math.Min(remain, 5);
        return this.GetMod(target%mod1, newR);
    }

    private decimal mod1 = 1000000007;
 


    public class Reader {
        public static bool IsDebug = true;
        private static System.IO.StringReader SReader;
        private static string InitText = @"


101

";
        public static string ReadLine() {
            if(IsDebug) {
                if(SReader == null) {
                    SReader = new System.IO.StringReader(InitText.Trim());
                }
                return SReader.ReadLine();
            } else {
                return Console.ReadLine();
            }
        }
    }
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0