From f1edf0c5e0e9ca3e7d700aa4c3fbb03a3e3de760 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sun, 8 May 2016 12:41:56 +0800 Subject: [PATCH] Create 1162_lelouch1.pas From https://vijos.org/p/1162/solution --- VIJOS/1162_lelouch1.pas | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 VIJOS/1162_lelouch1.pas diff --git a/VIJOS/1162_lelouch1.pas b/VIJOS/1162_lelouch1.pas new file mode 100644 index 0000000..b493ad8 --- /dev/null +++ b/VIJOS/1162_lelouch1.pas @@ -0,0 +1,55 @@ +var +i,j,n,min,max,x,y:longint; +s:Array[1..10000000]of shortint; +function long(x,k:longint):longint; +begin +long:=0; +while x>0 do +begin +inc(long); +x:=x div k; +end; +end; +function power(a,b:longint):longint; +var +t:integer; +begin +power:=1; +for t:=1 to b do +power:=power*a; +end; +function num(a,b,l,k:longint):longint; +var +i:longint; +begin +num:=0; +for i:=1 to l do +if odd(i) +then inc(num, a*trunc(power(k,l-i)) ) +else inc(num, b*trunc(power(k,l-i)) ); +end; +procedure all(k:longint); +var +i,j,l,l1,l2,m:longint; +begin +l1:=long(min,k); +l2:=long(max,k); +for i:=1 to k-1 do +for j:=0 to k-1 do +if i<>j then +begin +for l:=l1 to l2 do +begin +m:=num(i,j,l,k); +if (m<=max)and(m>=min) then +inc(s[m]); +end; +end; +end; +begin +readln(x,y,min,max,n); +fillchar(s,sizeof(s),0); +for i:=x to y do all(i); +for i:=min to max do +if s[i]=n then writeln(i); +end.