杭电联赛-Assertion-题解

Assertion[断言]

Problem Description[题目描述]

Alice boldly asserts to you that if you divide mm items into nn groups, there will definitely be one group with a quantity of items greater than or equal to dd.

Due to Alice’s excessive self-confidence, she is unaware that some of her assertions are actually incorrect. Your task is to determine whether Alice’s assertion is correct. If Alice’s assertion is true, output ‘Yes’; otherwise, output ‘No’.

爱丽丝大胆地向你断言,如果你把 mm 个物品分成 nn 组,肯定会有一组物品的数量大于或等于 dd

由于爱丽丝过于自信,她没有意识到她的一些断言实际上是不正确的。你的任务是确定爱丽丝的断言是否正确。

如果Alice的断言为真,输出"Yes",否则,输出"No"。

Input[输入格式]

The input consists of multiple test cases. The first line contains a single integer T(1T105)T (1≤T≤10^5) — the number of test cases. Description of the test cases follows.

The first line of each test case contains three integers n,m,d (2m109,1n<m,0d109)n,m,d (2≤m≤10^9,1≤n<m,0≤d≤10^9), nn and mm represent the number of groups and the quantity of items, respectively, in Alice’s assertion. The symbol dd signifies Alice’s claim that there will always be at least one group with a quantity of items greater than or equal to dd.

第一行包含一个整数 T(1T105)T(1≤T≤10^5) 表示测试用例的数量。

接下来 TT 行,每一行包含三个整数 n,m,d(2m109,1n<m,0d109)n,m,d (2≤m≤10^9,1≤n<m,0≤d≤10^9)

nnmm 分别表示Alice断言中的组数和项数。

符号dd表示Alice的声明,即总有至少一个组的物品数量大于或等于 dd

Output[输出格式]

For each set of data, output a string. If Alice’s assertion is correct, output ‘Yes’; otherwise, output ‘No’.

对于每组数据,输出一个字符串。如果Alice的断言是正确的,输出"Yes",否则,输出"No"。

Sample Input[样例输入]

3 
1 2 1 
2 3 2 
3 10 4

Sample Output[样例输出]

Yes 
Yes 
Yes

1009 Assertion

思路

这题应该是这一天杭电联赛最简单的一道了 因为别的我都不会做

思路很简单,分组后有最多物品的一组的最少物品数x为
x = n / m + (n % m == 0) ? 0 : 1
比较x和d即可。

C++代码

#include <iostream>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    int t;
    cin >> t;
    while(t--) {
        int n, m, d, tmp;
        cin >> n >> m >> d;
        tmp = m / n;
        if(tmp >= d) {
            cout << "Yes\n";
            continue;
        }
        cout << ((m % n != 0 and tmp + 1 >= d) ? "Yes\n" : "No\n");
    }
    return 0;
}

AC截图


杭电联赛-Assertion-题解
https://winterl-blog.netlify.app/2023/07/18/杭电联赛-Assertion-题解/
作者
winterl
发布于
2023年7月18日
许可协议