結果
問題 | No.492 IOI数列 |
ユーザー |
![]() |
提出日時 | 2017-03-13 13:49:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 2,683 bytes |
コンパイル時間 | 850 ms |
コンパイル使用メモリ | 105,984 KB |
実行使用メモリ | 18,432 KB |
最終ジャッジ日時 | 2024-06-30 00:38:40 |
合計ジャッジ時間 | 1,873 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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) {if(num == 0) {return 0;}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 = @"999999999999999999";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();}}