Submission #1516086
Source Code Expand
import std.array; import std.stdio; import std.range; import std.algorithm; import std.format; import std.bigint; import std.functional; import std.string; import std.conv; void main() { long A, B; string input = readln(); input.formattedRead("%s %s", &A, &B); solve(A - 1, B).writeln(); } long solve(long A, long B) { return (B - f(B.to!string) + 1) - (A - f(A.to!string) + 1); } long f(string n) { long first = n.take(1).to!long; return iota(first + 1).filter!(x => x != 4 && x != 9).map!((x) { if ((x + 1) * (10 ^^ (n.length - 1)) - 1 <= n.to!long) { return g(n.length - 1); } else { return f(n[1 .. $]); } }).sum(); } long g(long m) { return 8 ^^ m; }
Submission Info
Submission Time | |
---|---|
Task | D - 禁止された数字 |
User | kotet |
Language | D (DMD64 v2.070.1) |
Score | 0 |
Code Size | 729 Byte |
Status | CE |
Compile Error
/usr/include/dmd/phobos/std/conv.d(298): Error: template std.conv.toImpl cannot deduce function from argument types !(long)(Take!string), candidates are: /usr/include/dmd/phobos/std/conv.d(364): std.conv.toImpl(T, S)(S value) if (isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && !isNullToStr!(S, T)) /usr/include/dmd/phobos/std/conv.d(478): std.conv.toImpl(T, S)(ref S s) if (isRawStaticArray!S) /usr/include/dmd/phobos/std/conv.d(494): std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) : T) && !isExactSomeString!T && !is(typeof(T(value)))) /usr/include/dmd/phobos/std/conv.d(545): std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == struct) && is(typeof(T(value)))) /usr/include/dmd/phobos/std/conv.d(594): std.conv.toImpl(T, S)(S value) if (!isImplicitlyConvertible!(S, T) && is(T == class) && is(typeof(new T(value)))) /usr/include/dmd/phobos/std/conv.d(298): ... (9 more, -v to show) ... ./M...