CODEFORCES Problem-1954A.Painting the Ribbon(好题,非常打开思维)

time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

Alice and Bob have bought a ribbon consisting of n𝑛 parts. Now they want to paint it.

First, Alice will paint every part of the ribbon into one of m𝑚 colors. For each part, she can choose its color arbitrarily.

Then, Bob will choose at most k𝑘 parts of the ribbon and repaint them into the same color (he chooses the affected parts and the color arbitrarily).

Bob would like all parts to have the same color. However, Alice thinks that this is too dull, so she wants to paint the ribbon in such a way that Bob cannot make all parts have the same color.

Is it possible to paint the ribbon in such a way?

Input

The first line contains one integer t𝑡 (1≤t≤1000) — the number of test cases.

Each test case consists of one line containing three integers n𝑛, m𝑚 and k𝑘 (1≤m,k≤n≤50) — the number of parts, the number of colors and the number of parts Bob can repaint, respectively.

Output

For each test case, print YES if Alice can paint the ribbon so that Bob cannot make all parts have the same color. Otherwise, print NO.

You can print every letter in any register. For example, Yes, yes, yEs will all be recognized as positive answer.

这道题目的大致意思是:有n个部分要上色,bob选择最多m种颜色上色,bob不希望颜色都一样,alice希望颜色都一样,alice可以改变k个部分,问是否颜色一致,若是“NO”不是“YES”

这道题跟算法就基本无关了,这就不是程序竞赛了,这就是数学竞赛了,数学好的同学应该会有好的办法来解决他,直接放代码吧:

#include <bits/stdc++.h>
using namespace std;

int t,n,m,k;

int main()
{
	cin >> t;
	while(t--){
		cin >> n >> m >> k;
		int max_color = (n + m - 1) / m;
		if(max_color >= n - k) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

简单解释一下,max_color和n - k(也就是alice改变不了的部分)做比较,如果max_color大于等于n - k说明所有都可以是一样的颜色

以下是用库函数ceil求max_color代码:

​
#include <bits/stdc++.h>
using namespace std;

int t,n,m,k;

int main()
{
	cin >> t;
	while(t--){
		cin >> n >> m >> k;
		int max_color = ceil(n / m);
		if(max_color >= n - k) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	return 0;
}

​
​
#inlcude <cmath> || #include <bits/stdc++.h>
ceil(double(m) / n) m / n 向上取整
floor(double(m) / n) .....向下取整

​

加油

  • 23
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用内容,Codeforces Round 511 (Div. 1)是一个比赛的名称。然而,引用内容中没有提供与这个比赛相关的具体信息或问题。因此,我无法回答关于Codeforces Round 511 (Div. 1)的问题。如果您有关于这个比赛的具体问题,请提供更多的信息,我将尽力回答。 #### 引用[.reference_title] - *1* [Codeforces Round 860 (Div. 2)题解](https://blog.csdn.net/qq_60653991/article/details/129802687)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Codeforces Round 867 (Div. 3)(A题到E题)](https://blog.csdn.net/wdgkd/article/details/130370975)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Codeforces Round 872 (Div. 2)(前三道](https://blog.csdn.net/qq_68286180/article/details/130570952)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值