官方题解http://blog.csdn.net/skywalkert/article/details/47061925
传送门
http://codevs.cn/problem/3943/
http://codevs.cn/problem/3945/
http://codevs.cn/problem/3944/
T1 数学奇才琪露诺
题目大意
对于一个数,它的各个位的数相加之和为sum(x),那么sum(x)k∗p+q=x ,输出给定区间[L,R]内的所有x,及其个数
题解
[L,R]的范围是109,所以sum(x)max=81,我们可以看出上面方程解x,sum(x)与x唯一对应,所以枚举sum(x),算出[L,R]内的x输出即可
var
x:array[0..100000]of longint;
i,j:longint;
k,p,q,l,r:longint;
a,ans:int64;
function sum(a:longint):longint;
var st:string; i,b,c,d:longint;
begin
str(a,st); b:=0; c:=0;
for i:=1 to length(st) do
begin
val(st[i],b);
inc(c,b);
end;
exit(c);
end;
begin
readln(k,p,q);
readln(l,r);
for i:=0 to 81 do
begin
a:=i;
for j:=2 to k do
a:=a*i;
if (p*a+q>=l)and(p*a+q<=r)and(sum(p*a+q)=i)
then begin inc(ans); x[ans]:=p*a+q; end;
end;
writeln(ans);
for i:=1 to ans do
write(x[i],' ');
end.