View Code of Problem 104

#include <stdio.h>
#include <string.h>
#include <math.h>

int main()
{
	float sum1,sum2;
	float sum3,sum4;
	float n,a,b,t,i;
     while(scanf("%f %f %f %f",&n,&a,&b,&t)!=EOF)
	 {
	 n=n*1000;
     sum1=n+t*b;
	 sum2=a*t;
	 sum3=n;
	 sum4=0;
	 if(sum2>=sum1)
	 {
		 for(i=1;i<=t;i++)
		 {
			 sum3=sum3+b;
		     sum4=sum4+a;
			 if(sum3==sum4)
			 {
				 printf("%.2f\n",i);
				 break;
			 }
		 }
	 }
	 else
	 {
		 printf("NO\n");
	 }
	 }
}

Double click to view unformatted code.


Back to problem 104