Assertion

原题目:

Problem Description

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

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'.

Input

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

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

Output

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

Sample Input

3
1 2 1
2 3 2
3 10 4

Sample Output

Yes

Yes

Yes

翻译:

输入由多个测试用例组成。第一行包含单个整数T(1<=t<=10^5)测试用例的数量。下面是测试用例的描述。

每个测试用例的第一行包含三个整数n,m,d (2<=m<=10^9,1<= n<m,0<=d<=10^9),n和m分别表示Alice断言中的组数和项数。符号d表示Alice的断言,即总有至少一个组的项目数量大于或等于d。

输入由多个测试用例组成。第一行包含单个整数T(1<=t<=10^5)测试用例的数量。下面是测试用例的描述。

每个测试用例的第一行包含三个整数n,m,d (2<=m<=10^9,1<=n<m,0<=d<=10^9),n和m分别表示Alice断言中的组数和项数。符号d表示Alice的断言,即总有至少一个组的项目数量大于或等于d。

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

思路:

可以想象为:将V升的水装入n个杯子,是否一定存在某个杯子内的水>=d升,首先求的每个杯子内的水的平均值V/n,若有余数k,k一定小于V/n,所以部分杯子内装水V/n+1,最后判断它与d的大小关系。

 

解决方案:

项目数除以组数,得到平均值,如果整除,则直接与d比较大小,如果不整除,则平均值+1再与d比较大小,大于则必定存在。

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,m,d;
	cin>>t;
	while(t--)
	{
		scanf("%d %d %d",&n,&m,&d);//cin会超时
		if(m%n==0&&m/n>=d)
		{
			printf("Yes\n");//cout会超时
		}
		else if(m%n!=0&&m/n+1>=d)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值