四川大学(新生赛)papaya的传送门

四川大学(新生赛)papaya的传送门,第1张

四川大学(新生赛)papaya的传送门

题目:https://ac.nowcoder.com/acm/contest/25625/L


解题思路:
这就是一道水题。。。求出点到圆心的距离,然后减去半径就是从起点到机场的距离d,需要判断当前是否在机场,还有就是k是否大于d,如果大于那么就需要两次传送,第一次到一个机场外的点,第二次从这个点到机场。,如果k

#include 
#include 
using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        
        long long x,y,R,k;
        cin >> x >> y >> R >> k;
        
        double d = sqrt(x*x + y*y)-R;
        if(d <= 1e-6){
            cout << 0 << endl;
            continue;
        }
        if(k > d + 2*R){
            cout << 2 << endl;
            continue;
        }
//         long long dd = (d+0.999999);
//         long long ans =dd/k;
//         if(dd%k) ans+=1;
        long long ans = ceil(d/k);//向上取整,不管小数点后是多少(除0以外)都加一
        
        cout << ans << endl;
    }
    
    
    return 0;
}
个人学习笔记

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5659035.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存