Pagini recente » Cod sursa (job #2976783) | Cod sursa (job #2931898) | Cod sursa (job #560050) | Cod sursa (job #1336300) | Cod sursa (job #2076266)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin ("pod.in");
ofstream fout ("pod.out");
int n,b,k;
int g[100001];
int solutie(int L)
{
int st=0,ok=1;
while(st<=L && ok==1)
{
if(g[st+1]==0)
st++;
else
if(g[st+k]==0)
st=st+k;
else
ok=0;
}
return ok;
}
int main()
{
fin>>n>>b>>k;
for(int i=1;i<=b;i++)
{
int c;
fin>>c;
g[c]=-1;
}
int nr=0,L=n;
while(L>1)
{
if(solutie(L)==1)
nr++;
L=L/2;
}
fout<<nr;
return 0;
}