记录编号 |
22288 |
评测结果 |
AAAWWAWWWW |
题目名称 |
八 |
最终得分 |
40 |
用户昵称 |
wangwangdog |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.004 s |
提交时间 |
2010-11-18 14:50:37 |
内存使用 |
0.40 MiB |
显示代码纯文本
#include<stdio.h>
FILE *fin,*fout;
long long all,i,j,a[16],b[16],c[16],d[10000],e[10000],n,shang,xia,p,q,t1;
long long make(long a,long b)
{long long qq;
if(b>a){long pp=a;a=b;b=pp;}
do
{
qq=a%b;
a=b;
b=qq;
}while(qq!=0);
return a;
}
int main()
{
fin=fopen("eight.in","rb");
fout=fopen("eight.out","wb");
fscanf(fin,"%ld\n",&n);
for(i=1;i<=n;i++)
fscanf(fin,"%lld",&a[i]);
fscanf(fin,"\n");
fscanf(fin,"%lld%lld",&xia,&shang);
for(i=1;i<=n;i++)
b[i]=8/make(a[i],8)*a[i];
long long tt=0;
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{
tt++;
long long ttt=a[i]/make(a[i],a[j])*a[j];
d[tt]=ttt/make(8,ttt)*8;
}
for(i=1;i<=n;i++)
{
if(b[i]<=shang)
{
c[i]=(shang/b[i])-(xia/b[i]);
}
else c[i]=0;
}
for(i=1;i<=tt;i++)
{
if(d[i]<=shang)
{
e[i]=(shang/d[i])-(xia/d[i]);
}
else e[i]=0;
}
p=xia,q=p;
p=p%8;
p=(8-p)+q;
t1=p;
p=shang;q=p;
p=p%8;
p=q-p;
if(p>=xia&&p<=shang&&t1<=shang&&t1>=xia)
all=((p-t1)/8)+1;
else all=0;
for(i=1;i<=n;i++)
all=all-c[i];
for(i=1;i<=tt;i++)
all=all+e[i];
fprintf(fout,"%lld",all);
fclose(fin);
fclose(fout);
return 0;
}