比赛 |
20101118 |
评测结果 |
AAAWWAWWWW |
题目名称 |
八 |
最终得分 |
40 |
用户昵称 |
wangwangdog |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-18 11:06:29 |
显示代码纯文本
#include<stdio.h>
FILE *fin,*fout;
long all,i,j,a[16],b[16],c[16],d[10000],e[10000],n,shang,xia,p,q,t1;
long make(long a,long b)
{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,"%ld",&a[i]);
fscanf(fin,"\n");
fscanf(fin,"%ld%ld",&xia,&shang);
for(i=1;i<=n;i++)
b[i]=8/make(a[i],8)*a[i];
long tt=0;
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{
tt++;
long ttt=a[i]/make(a[i],a[j])*a[j];
d[tt]=ttt/make(8,ttt)*8;
}
for(i=1;i<=n;i++)
{
p=xia,q=p;
p=p%b[i];
p=(b[i]-p)+q;
t1=p;
p=shang;q=p;
p=p%b[i];
p=q-p;
if(p>=xia&&p<=shang&&t1<=shang&&t1>=xia)
c[i]=((p-t1)/b[i])+1;
else c[i]=0;
}
for(i=1;i<=tt;i++)
{
p=xia,q=p;
p=p%d[i];
p=(d[i]-p)+q;
t1=p;
p=shang;q=p;
p=p%d[i];
p=q-p;
if(p>=xia&&p<=shang&&t1<=shang&&t1>=xia)
e[i]=((p-t1)/d[i])+1;
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,"%ld",all);
fclose(fin);
fclose(fout);
return 0;
}