[3752]:Is the one been second-killed first?

本文探讨了一个经典的分配问题:如何将重量为m克的蛋糕平均分配给n个孩子,每个孩子得到的部分重量必须是偶数克。文章提供了一种通过判断蛋糕总重量是否为偶数来快速解决问题的方法,并附带了简单的C语言实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem Description
Long long ago, a problem was spread all over the world , but no one could solve it . Now, due to the Internet , it has been solved perfectly(See figure 1).

这里写图片描述

Now here’s a problem much harmonious.
ErEr has big cake weighing m grams , at the same time he has n children . and every children want a part of the cake weighs even number(偶数) of grams. The children are extremely hungry and want to start their meal as soon as possible, that’s why you should help them and find out, if they can divide the cake in the way they want. For sure, each of them should get a part of positive weight.

Input
The first line of input gives the number of cases, T (at most 100).
each case has there numbers m,n. (1<=m<=10000,1<=n<=100)

Output
Print YES, if the boys can divide the cake into n parts, each of them weighing even number of kilos; and NO in the opposite case.

Sample Input
2
10 2
11 2

Sample Output
YES
NO

解题关键在于:上面加粗部分,意思就是说n(kg)的蛋糕,分成若干份,是否存在每一份都是偶数kg重

/*
  author : Yangchengfeng
*/


#include<stdio.h>

int main()
{
    int testTimes;
    scanf("%d", &testTimes);
    while(testTimes--){
        int n, m;
        scanf("%d%d", &n, &m);
        if(n%2==0){ // 点
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    return 0;
}

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值