結果

問題 No.492 IOI数列
ユーザー 14番14番
提出日時 2017-03-13 13:47:17
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,601 bytes
コンパイル時間 3,443 ms
コンパイル使用メモリ 106,444 KB
実行使用メモリ 24,912 KB
最終ジャッジ日時 2023-09-12 12:13:34
合計ジャッジ時間 4,717 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
24,912 KB
testcase_01 AC 66 ms
20,948 KB
testcase_02 WA -
testcase_03 AC 66 ms
22,880 KB
testcase_04 AC 68 ms
20,920 KB
testcase_05 AC 66 ms
20,836 KB
testcase_06 AC 66 ms
20,928 KB
testcase_07 AC 66 ms
18,668 KB
testcase_08 AC 67 ms
20,816 KB
testcase_09 AC 66 ms
20,824 KB
testcase_10 AC 63 ms
20,808 KB
testcase_11 AC 66 ms
20,708 KB
testcase_12 AC 66 ms
20,716 KB
testcase_13 AC 63 ms
22,888 KB
testcase_14 AC 63 ms
20,704 KB
testcase_15 AC 67 ms
20,720 KB
testcase_16 AC 66 ms
20,836 KB
testcase_17 AC 66 ms
22,828 KB
testcase_18 AC 67 ms
22,968 KB
testcase_19 AC 67 ms
22,864 KB
testcase_20 AC 67 ms
22,888 KB
testcase_21 AC 66 ms
20,776 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
            long num = long.Parse(Reader.ReadLine());
            Console.WriteLine(GetAns(num));
            Console.WriteLine(GetNum(num%11));
        }

        private const decimal ModNum = 1000000000 + 7;
        private Dictionary<long, decimal> Mul10Dic = new Dictionary<long, decimal>();
        private decimal Get10Mul(long num) {
            if(Mul10Dic.ContainsKey(num)) {
                return Mul10Dic[num];
            }
            
            decimal ans = 0;
            if(num > 5) {
                long half = num/2;
                ans = Get10Mul(half)*Get10Mul(num-half)%ModNum;
            } else {
                ans = 1;
                for(int i=1; i<=num; i++) {
                    ans*=100;
                }
                ans = ans % ModNum;
            }
            Mul10Dic[num] = ans;
            return ans;
        }

        private Dictionary<long, decimal> dic = new Dictionary<long, decimal>();

        private decimal GetAns(long num) {
            if(dic.ContainsKey(num)) {
                return dic[num];
            }
            decimal ans = 0;
            if(num <= 5) {
                ans = GetNum(num)%ModNum;
            } else {
                long half = num / 2;
                decimal tmp = GetAns(num-half)*Get10Mul(half)%ModNum;
                tmp = tmp + GetAns(half);
                ans = tmp%ModNum;
            }
            dic[num] = ans;
            return ans;
        }
        private long GetNum(long num) {
            long ret = 1;
            for(int i=2; i<=num; i++) {
                ret = ret * 100 + 1;
            }
            return ret;
        }

        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