結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:19:54 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 313 ms / 1,000 ms |
コード長 | 2,230 bytes |
コンパイル時間 | 2,503 ms |
コンパイル使用メモリ | 114,172 KB |
実行使用メモリ | 60,816 KB |
最終ジャッジ日時 | 2024-10-01 07:11:18 |
合計ジャッジ時間 | 8,014 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 103 |
コンパイルメッセージ
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++) {long ret = GetNum(i.ToString());if(ret >= 0) {ans+=ret;}ret = GetNum(i.ToString()+i);if(ret >= 0) {ans+=ret;}}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 -1;}if(tmp.Length >= 10) {return -1;}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++) {long ret = GetNum(i + tmp + i);if(ret >= 0) {ans+=ret;} else {break;}}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();}}