Aman & Mr.Sharma

Problem:-

On a distant planet far away from Earth lives a boy named Aman.He loves to run everyday.But his running distance is directly affected by how much horlicks his mother mixed in his milk today.If his mother has mixed x grams of horlicks,then Aman will be capable of running 100*x meters at most on that day.
Aman’s instructor, Mr.Sharma ,is a very strict yet very caring.Everyday he asks Aman to run around a circle of radius r once.If Aman is able to complete the circle,he would get a toffee.
Note:Take value of pie=22/7.
CONSTRAINTS:
1<=d<105
1<=r<106
1<=x<=104
INPUT:
First line contains d,no. of days Aman goes to his instructor.Next d lines each contain r,radius of circle and x,amount of horlicks.
OUTPUT:
Print total number of toffees Aman would finally have at the end of d days.
SAMPLE INPUT
 
3
3 2
5 2
1 2
SAMPLE OUTPUT
 
3
Time Limit:5.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

solution:-

#include<stdio.h>
void main()
{
     int d,r,x,s=0,i,dis,p;
     scanf(“%d”,&d);
     for(i=1;i<=d;i++)
     {
        scanf(“%d%d”,&r,&x);
dis=100*x;
        p=2*(3.142857)*r;
        if(dis>=p)
         s=s+1;
     }
     printf(“%d”,s);
}

Leave a Reply

Your email address will not be published.