P1426 小鱼会有危险吗 <洛谷> (C++)

找数学关系..水题..具体看代码..

#include <iostream>
#include <cstdio>
#define ll long long

using namespace std ;

int main(){
    double s , x ;
    cin >> s >> x ;
    double v = 7 , dis = 0 ;
    for ( ; dis <= s - x ; v *= 0.98 , dis += v ) ;
    if ( dis + v * 0.98 >= s + x ) cout << "n" << endl ;
    else cout << "y" << endl ;
    return 0 ;
}

猜你喜欢

转载自www.cnblogs.com/Cantredo/p/9703270.html