Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uses math;
- var
- q:array[0..100001,0..3] of longint;
- a,b:array[0..500010] of longint;
- x,y,yy,i,j,z,t,q1,q2:longint;
- st,stt:array[0..50100] of string;
- p:array[1..50000] of boolean;
- s,ss,sw:string;
- // x,y,xx,yy:extended;
- c:char;
- w:array['a'..'z'] of longint;
- xx,n,m,k,ans,tp:int64;
- function nok(a,b:int64):int64;
- var
- i,j:int64;
- begin
- i:=a;j:=b;
- while i*j<>0 do
- if i>j then i:=i mod j else j:=j mod i;
- nok:=(a*b) div (i+j);
- end;
- begin
- assign(input,'input.txt');reset(input);
- assign(output,'output.txt');rewrite(output);
- read(n,m);
- for i:=1 to m do read(a[i]);
- z:=0;
- for i:=1 to m do
- begin
- for j:=1 to z do
- begin
- tp:=nok(q[j,1],a[i]);
- if tp<=n then begin
- inc(z);
- q[z,1]:=tp;q[z,2]:=q[j,2]*(-2);
- end;
- end;
- inc(z);
- q[z,1]:=a[i];q[z,2]:=1;
- end;
- ans:=0;
- for i:=1 to z do
- begin
- ans:=ans+(n div q[i,1])*q[i,2];
- end;
- write(ans);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement