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; long solve_one(long N) { string n = N.to!string; int m = n.length.to!int; auto dp = new long[][][][](m+1, 2, 2, 7); // 桁, n未満か, 前の数字が1か, これまで何個の12があったか dp[0][0][0][0] = 1; foreach (i; 0..m) { foreach (j; 0..2) { foreach (k; 0..2) { foreach (l; 0..6) { int digit = j ? 10 : (n[i]-'0'+1); foreach (d; 0..digit) { dp[i+1][j|(d 1) ans += 1; //if (s[1][0] == '2' && s[1][$-1] == '1') ans -= 1; ans.writeln; //ans1.writeln; //ans2.writeln; }