結果
問題 | No.491 10^9+1と回文 |
ユーザー |
![]() |
提出日時 | 2017-03-10 23:17:13 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,067 bytes |
コンパイル時間 | 906 ms |
コンパイル使用メモリ | 111,868 KB |
実行使用メモリ | 28,884 KB |
最終ジャッジ日時 | 2024-06-24 08:37:03 |
合計ジャッジ時間 | 6,196 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 61 |
コンパイルメッセージ
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++) {long ret = GetNum(i + tmp + i);ans += ret;if(ret == 0) {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();}}