結果
問題 | No.491 10^9+1と回文 |
ユーザー |
|
提出日時 | 2017-03-10 23:45:45 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,311 bytes |
コンパイル時間 | 3,411 ms |
コンパイル使用メモリ | 146,348 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 18:19:39 |
合計ジャッジ時間 | 4,351 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 WA * 61 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop, core.stdc.stdio;bool is_kaibun(string s) {int n = s.length.to!int;foreach (i; 0..n/2) {if (s[i] != s[n-i-1]) return false;}return true;}void main() {long N = readln.chomp.to!long;long M = 10^^9;long a = N / M;if (a == 0) {writeln(0);return;}string s = a.to!string;long b = s.length;long ans = 0;foreach (i; 1..b+1) {if (i == b) {ans += 10 ^^ (i/2+i%2-1) * (s[0].to!string.to!long-1);}else {if (i == 1)ans += 9;elseans += 10^^(i/2+i%2);}}long keta = b/2+b%2-1;keta = keta/2+keta%2;long base = a - (a % 10^^(b-1));foreach (i; 0..10^^keta) {string aida;aida = i.to!string;long nnn;if (b > 1) {nnn = base + (aida).to!long*10 + s[0].to!string.to!long;}else {nnn = base;}if (!(is_kaibun(nnn.to!string))) continue;long mmm = nnn*10^^9 + nnn;if (mmm <= N) ans++;}ans.writeln;}