Cod sursa(job #202565)

Utilizator neagu1000123Neagu Rares Florian neagu1000123 Data 9 august 2008 20:01:23
Problema Pascal Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <stdio.h>

int main()
{
 	 freopen("pascal.in","r",stdin);
 	 freopen("pascal.out","w",stdout);
 	 long r,d;
 	 scanf("%ld %ld",&r,&d);
	 long i;
	 if (d==1)
	 {
	  	 printf("%ld",r);
	  	 return 0;
	 }
	 int j=r-1;
	 int cond1,cond2,cond3,cate=0;
	 for (i=1;i<r;i++)
	 {
	  	  cond1=cond2=cond3=0;
	  	  if (i>=d)
	  	  {
		  	  cond1=1;
        }
        if ((i-j)>=d)
        {
		  	  cond2=1;
        }
        if (j>=d)
        {
		  	  cond3=1;
        }
        if (cond1 && (cond2 || cond3))
        {
		  	  cate++;
        }
    }
	 printf("%ld",cate);
	 return 0;
}