CF 1872 A

A. Two Vessels

简单题。先计算杯子a和杯子b里水的差值,在计算需要用c杯子舀几次水就行

\[Ans=ceil(|a-b|/2c) \]

代码

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int t;
int a, b, c;
signed main()
{
    std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> t;
    while(t--)
    {
        cin >> a >> b >> c;
        cout << ceil(abs(a - b) * 1.0 / 2 / c) << endl;
    }
    return 0;
}
posted @ 2023-09-08 09:16  铜锣骚  阅读(42)  评论(0)    收藏  举报