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.
Example:
Input: d = 3, r = [3,5,1], x = [2,2,2]
Output: 3
Approach
C++
#include <bits/stdc++.h>using namespace std;int runAroundCircle(int d, int r[], int x[]){int cnt = 0;for (int i = 0; i < d; i++){int p = (2 * 22 * r[i]) / 7;if (p <= x[i] * 100)cnt++;}return cnt;}int main(){int d = 3;int r[d] = {3, 5, 1};int x[d] = {2, 2, 2};cout << runAroundCircle(d, r, x) << "\n";return 0;}
No comments:
Post a Comment