結果
問題 |
No.491 10^9+1と回文
|
ユーザー |
![]() |
提出日時 | 2017-03-10 23:16:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,975 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 114,652 KB |
実行使用メモリ | 129,388 KB |
最終ジャッジ日時 | 2024-06-24 08:35:48 |
合計ジャッジ時間 | 20,162 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 93 TLE * 8 MLE * 2 |
コンパイルメッセージ
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; decimal inpt = decimal.Parse(Reader.ReadLine()); this.max = inpt; long ans = 0; for(int i=0; i<=9; i++) { ans += GetNum(i.ToString()); ans += GetNum(i.ToString()+i); } Console.WriteLine(ans); } private Dictionary<string, bool> flag = new Dictionary<string, bool>(); private Dictionary<decimal, bool> flagNum = new Dictionary<decimal, bool>(); private long GetNum(string tmp) { if(flag.ContainsKey(tmp)) { return 0; } flag[tmp] = true; decimal num = decimal.Parse(tmp); if(num*baseNum > max) { return 0; } if(tmp.Length >= 10) { return 0; } long ans = 0; if(!flagNum.ContainsKey(num)) { if(num > 0 && num.ToString().Length == tmp.Length) { ans++; } flagNum[num] = true; } for(int i=0; i<=9; i++) { ans += GetNum(i + tmp + i); } return ans; } private decimal max = 0; private decimal baseNum = 1000000000 + 1; public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 40000000000 "; 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(); } }