Pagini recente » Cod sursa (job #2223625) | Cod sursa (job #2309881) | Istoria paginii utilizator/carmenro33 | Cod sursa (job #1486836) | Cod sursa (job #37597)
Cod sursa(job #37597)
const fi='distincte.in'; fo='distincte.out';
maxim=60000;
type userdefined=1..maxim;
arr=array[1..maxim] of userdefined;
var m,k,n,i,j:userdefined;
v:arr;
a:array[1..2,1..maxim] of userdefined;
t:text;
procedure init;
begin
assign(t, fi);
reset(t);
read(t, n,k,m);
readln(t);
for i:=1 to n do
readln(t, v[i]);
for i:=1 to m do readln(t, a[1,i], a[2,i]);
close(t)
end;
function exista(v_temp:arr;a:longint):boolean;
var i:longint;
begin
exista:=false;
if a>1 then
for i:=1 to a-1 do
if v_temp[i]=v_temp[a] then exista:=true;
end;
function suma(i,j:userdefined):longint;
var v_temp:arr;
a:longint;
sum,temp:longint;
begin
for a:=1 to j-i+1 do
begin
v_temp[a]:=v[a+i-1];
write(v_temp[a]:3);
end;
writeln;
sum:=0;
a:=1;
while a<=j-i+1 do
begin
if sum>=666013 then sum:=sum-666013;
if not(exista(v_temp, a)) then sum:=sum+v_temp[a];
a:=a+1;
end;
{temp:=1;
sum:=0;
while temp<=j-i+2 do
begin
if sum>=666013 then sum:=sum-666013;
sum:=sum+v_temp[temp];
temp:=temp+1;
end;}
suma:=sum;
end;
begin
init;
writeln(n:3,k:3,m:3);
for i:=1 to n do
writeln(v[i]:3);
for i:=1 to m do
writeln(a[1,i]:3, a[2,i]:3) ;
assign(t, fo);
rewrite(t);
for i:=1 to m do
writeln(t, suma(a[1, i], a[2, i]));
close(t);
end.