杭电联赛-Assertion-题解
Assertion[断言]
Problem Description[题目描述]
Alice boldly asserts to you that if you divide items into groups, there will definitely be one group with a quantity of items greater than or equal to .
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’.
爱丽丝大胆地向你断言,如果你把 个物品分成 组,肯定会有一组物品的数量大于或等于 。
由于爱丽丝过于自信,她没有意识到她的一些断言实际上是不正确的。你的任务是确定爱丽丝的断言是否正确。
如果Alice的断言为真,输出"Yes",否则,输出"No"。
Input[输入格式]
The input consists of multiple test cases. The first line contains a single integer — the number of test cases. Description of the test cases follows.
The first line of each test case contains three integers , and represent the number of groups and the quantity of items, respectively, in Alice’s assertion. The symbol signifies Alice’s claim that there will always be at least one group with a quantity of items greater than or equal to .
第一行包含一个整数 表示测试用例的数量。
接下来 行,每一行包含三个整数
和 分别表示Alice断言中的组数和项数。
符号表示Alice的声明,即总有至少一个组的物品数量大于或等于 。
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 4Sample Output[样例输出]
Yes
Yes
Yes思路
这题应该是这一天杭电联赛最简单的一道了 因为别的我都不会做
思路很简单,分组后有最多物品的一组的最少物品数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截图
