2784: 【提高】小 X 与煎饼达人(flip)
var
  a,f:array[1..10000000] of longint;
  b,i,j,n,s,x,y:longint;
begin
  read(b,n);
  for i:=1 to n do
    a[i]:=0;
  for i:=1 to n do
    begin
    readln(x,y);
    a[x]:=1-a[x];
    a[y+1]:=1-a[y+1];
    end;
  for i:=1 to b do
  begin
    if a[i]=1
    then s:=s+1;
    f[i]:=s mod 2;
  end;
  s:=0;
  for i:=1 to b do
    if f[i]=1
    then s:=s+1;
  writeln(s);
end.
                    
                
                
            
        
浙公网安备 33010602011771号