比赛 20101118 评测结果 AAAWWAWWWW
题目名称 最终得分 40
用户昵称 itachi 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-18 10:12:31
显示代码纯文本
program t4(input,output);
var
data:array[1..15]of longint;
a,b,n,i,j,sum:longint;
function js(i:longint):longint;
 var
 x,y,t,p,q:longint;
 begin
 if i>b then exit(0);
  x:=a div i;
  y:= x * i;
  if y<a then begin y:=y+i; x:=x+1; end;
  if y>b then exit(0);
   p:= b div i ;
   if p*i< a then exit(0);
   if p*i= y then exit(1);
   js:=p-x+1;


 end;
 function lcm(a,b:int64):int64 ;
  function gcd(x,y:int64):int64;
   begin
    if y=0 then gcd:=x
           else gcd:=gcd(y,x mod  y);
   end;
 begin
  lcm:=a*b div gcd(a,b);
 end;
begin
assign(input,'eight.in');
reset(input);
assign(output,'eight.out');
rewrite(output);
readln(n);
for i:= 1 to n do
begin
read(data[i]);
if lcm(8,data[i])= 8 then sum:=-1;
end;
readln(a,b);
close(input);
if sum=-1 then begin writeln(0); close(output); exit; end;

sum:=js(8);
for i:= 1 to n do
 begin
 sum:=sum-js(lcm(8,data[i]));
 end;

 for i:= 1 to n -1 do
   for j:= i+1 to n do
   sum:=sum+js(lcm(lcm(8,data[i]),data[j]));
   if sum>=0 then writeln(sum) else writeln(0);
   close(output);
end.