Create 1162_zdf995.pas

From https://vijos.org/p/1162/solution
pull/14/head
Kirigaya Kazuto 2016-05-08 12:40:07 +08:00
parent 237ea6611d
commit c5c33b5c45
1 changed files with 40 additions and 0 deletions

40
VIJOS/1162_zdf995.pas Normal file
View File

@ -0,0 +1,40 @@
program num;
var s:array[0..10000000] of integer;
l,a,b,c,d,t,h,w,p:int64;
i,j,m,n:longint;
begin
readln(a,b,c,d,t);
for i:=a to b do
begin
for j:=1 to i-1 do inc(s[j]);
for m:=0 to i-1 do
for n:=0 to i-1 do
if m<>n then
begin
w:=n;
p:=1;
l:=1;
while w<=d do
begin
l:=l+1;p:=p*i;
if l mod 2=0 then
begin
if m<>0 then
begin
w:=w+p*m;
if w<=d then s[w]:=s[w]+1;
end;
end
else
begin
if n<>0 then
begin
w:=w+p*n;
if w<=d then s[w]:=s[w]+1;
end;
end;
end;
end;
end;
for i:=c to d do if s[i]=t then writeln(i);
end.