CF1878C.Vasilije in Cacak

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Aca and Milovan, two fellow competitive programmers, decided to give Vasilije a problem to test his skills.

Vasilije is given three positive integers: nn, kk, and xx, and he has to determine if he can choose kk distinct integers between 11 and nn, such that their sum is equal to xx.

Since Vasilije is now in the weirdest city in Serbia where Aca and Milovan live, Cacak, the problem seems weird to him. So he needs your help with this problem.

两位同为竞技编程选手的好友阿卡(Aca)和米洛凡(Milovan)决定给瓦西利耶(Vasilije)出一道题,以检验他的能力。

瓦西利耶被给出三个正整数:nn、kk 和 xx;他需要判断能否在 11 到 nn 之间选出 kk 个互不相同的整数,使得它们的和恰好等于 xx。

由于瓦西利耶如今身处塞尔维亚最奇特的城市——阿卡和米洛凡居住的查查克(Cacak),这道题在他看来显得十分古怪。因此,他需要你的帮助来解决这个问题。

输入格式

The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases.

The only line of each test case contains three integers nn, kk and xx (1≤n≤2⋅1051 \le n \le 2 \cdot 10^5, 1≤k≤n1 \le k \le n, 1≤x≤4⋅10101 \le x \le 4 \cdot 10^{10}) — the maximum element he can choose, the number of elements he can choose and the sum he has to reach.

Note that the sum of nn over all test cases may exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4)—— 测试用例的数量。

每个测试用例仅有一行,包含三个整数 nn、kk 和 xx(1≤n≤2⋅1051 \le n \le 2 \cdot 10^5,1≤k≤n1 \le k \le n,1≤x≤4⋅10101 \le x \le 4 \cdot 10^{10})—— 分别表示他能选择的最大元素值、他能选择的元素个数,以及他需要达到的和。

注意:所有测试用例中 nn 的总和可能超过 2⋅1052 \cdot 10^5。

输出格式

For each test case output one line: "YES", if it is possible to choose kk distinct integers between 11 and nn, such that their sum is equal to xx, and "NO", if it isn't.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer).

对于每个测试用例,输出一行:如果能在 11 到 nn 之间选出 kk 个互不相同的整数,使其和恰好等于 xx,则输出 "YES";否则输出 "NO"。

你可以以任意大小写形式输出答案(例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被判为正确答案)。

输入输出样例

  • 输入#1

    12
    5 3 10
    5 3 3
    10 10 55
    6 5 20
    2 1 26
    187856 87856 2609202300
    200000 190000 19000000000
    28 5 2004
    2 2 2006
    9 6 40
    47202 32455 613407217
    185977 145541 15770805980

    输出#1

    YES
    NO
    YES
    YES
    NO
    NO
    YES
    NO
    NO
    NO
    YES
    YES

说明/提示

In the first test case n=5, k=3, x=10n = 5,\ k=3,\ x=10, so we can choose the numbers: 22, 33, 55, whose sum is 1010, so the answer is "YES".

In the second test case n=5, k=3, x=3n = 5, \ k=3, \ x=3, there is no three numbers which satisfies the condition, so the answer is "NO". It can be shown that there are no three numbers whose sum is 33.

在第一个测试用例中,n=5, k=3, x=10n = 5,\ k=3,\ x=10,因此我们可以选择数字:22、33、55,它们的和为 1010,所以答案是 “YES”。

在第二个测试用例中,n=5, k=3, x=3n = 5, \ k=3, \ x=3,不存在满足条件的三个数,因此答案是 “NO”。可以证明:不存在三个数,其和为 33。

输入解题思路,AI测评打分。不知道怎么写?

首页