667A - Pouring Rain - CodeForces Solution


geometry math *1100

Please click on ads to support us..

Python Code:

from math import pi

cup_diameter, initial_water_height, drinking_speed_in_ml_per_sec, growth_water_speed_in_cm_per_sec = map(int, input().split())

cup_radius = cup_diameter / 2

growth_water_speed_in_ml_per_sec = pi * cup_radius ** 2 * growth_water_speed_in_cm_per_sec

if growth_water_speed_in_ml_per_sec >= drinking_speed_in_ml_per_sec:
    print("NO")
else:
    speed_of_water_dicrease = drinking_speed_in_ml_per_sec - growth_water_speed_in_ml_per_sec
    initial_water_volume = pi * cup_radius ** 2 * initial_water_height

    print("YES")
    print(initial_water_volume / speed_of_water_dicrease)

C++ Code:

// Problem: A. Pouring Rain
// Contest: Codeforces - Codeforces Round #349 (Div. 2)
// URL: https://codeforces.com/contest/667/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms

/* 
     
     #WTFyouhere
                    ♕ABHINAV♕
     
        HUSTLE KARO BHASAD NHI..... 
          
                             
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
const unsigned int M = 1000000007;
//►►►►►►►►►►►►►►►►►►►►(⊙⊙)(☉_☉)(⊙⊙)►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►
ll power(ll a, ll b, ll m = M) {a %= m;ll res = 1;while (b > 0) {
if (b & 1)res = res * a % m;a = a * a % m;b >>= 1;}return res;}
ll gcd(ll x, ll y) {return (x ? gcd(y % x, x) : y);}
ll inv(ll n, ll m = M) {return power(n, m - 2, m);}
ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
ll nextgreaterelement(ll n) {auto digits = to_string(n);
next_permutation(begin(digits), end(digits));auto res = stoll(digits);return res;}
vector<int> factorize(int n) {vector<int> ans;for (int i = 2; i * i <= n; ++i) {
while (n % i == 0) {ans.push_back(i);n /= i;}}if (n != 1) {ans.push_back(n);}
for(int i=0;i<ans.size();i++)cout<<ans[i]<<" ";}
ll near_pow(ll q){ll ans = (ll)log2(q);return pow(2,ans);}
long long ceil(long long p, long long q) {if(p % q == 0) return (p / q);return (p / q) + 1;}
//►►►►►►►►►►►►►►►►►►►(⊙⊙)(☉_☉)(⊙⊙)►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►►


void reply()
{
    ll t;
    cin>>t;
    while(t--)
    {
                        
                              
    }
    
}


int main() {
	// your code goes here
	//reply();
	double d,h,v,e;
    cin>>d>>h>>v>>e;
    double pi=3.14159265356;
    double tmp;
    double r=d/2;
    double s=pi*r*r;
    tmp=v/s;
    double res=e-tmp;
    if(res>0) cout << "NO" << endl;
    else
    { cout << "YES"<<endl;
    cout<<fixed<<setprecision(15)<<-h/res<<endl;
    }
	
	
	
}


Comments

Submit
0 Comments
More Questions

967B - Watering System
152A - Marks
1398A - Bad Triangle
137A - Postcards and photos
1674D - A-B-C Sort
334A - Candy Bags
855A - Tom Riddle's Diary
1417A - Copy-paste
1038A - Equality
1061A - Coins
1676E - Eating Queries
1447A - Add Candies
1721D - Maximum AND
363C - Fixing Typos
1401A - Distance and Axis
658A - Bear and Reverse Radewoosh
1721E - Prefix Function Queries
977E - Cyclic Components
1140D - Minimum Triangulation
75C - Modified GCD
1722A - Spell Check
1722B - Colourblindness
1722D - Line
1722C - Word Game
1722G - Even-Odd XOR
552E - Vanya and Brackets
933A - A Twisty Movement
1722F - L-shapes
1196B - Odd Sum Segments
1325D - Ehab the Xorcist