結果
| 問題 |
No.492 IOI数列
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2017-03-13 13:47:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,601 bytes |
| コンパイル時間 | 2,419 ms |
| コンパイル使用メモリ | 105,856 KB |
| 実行使用メモリ | 18,432 KB |
| 最終ジャッジ日時 | 2024-06-30 00:38:18 |
| 合計ジャッジ時間 | 2,237 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 1 |
コンパイルメッセージ
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) {
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();
}
}
14番