Three Dice

[SDCPC2023] Three Dice

题面翻译

【题目描述】

骰子,是一种各面带有标记,以生成随机数的小型可投掷道具,通常用于桌上游戏。

最常见的骰子是一种小正方体,每个面上被标记了从 1 1 1 6 6 6 的数字。数字 n n n 1 ≤ n ≤ 6 1 \le n \le 6 1n6)通常由 n n n 个小圆点组成的图案来表示,其中 1 1 1 号与 4 4 4 号面的小圆点是红色的,而 2 2 2, 3 3 3, 5 5 5 6 6 6 号面的小圆点是黑色的。

小青鱼手中有三只骰子。有一天,他将这三只骰子投掷在桌子上,并观察了朝上的那一个面。他发现所有朝上的面中,红色的点数之和恰好为 A A A,而黑色的点数之和恰好为 B B B

然而,您对小青鱼的发现感到怀疑。您想要确认是否有可能投掷出三只骰子,使得所有朝上的面中,红色的点数之和恰好为 A A A,而黑色的点数之和恰好为 B B B

【输入格式】

每个测试文件仅有一组测试数据。

第一行输入两个整数 A A A B B B 0 ≤ A , B ≤ 100 0 \leq A,B \leq 100 0A,B100),表示朝上的红色点数之和与黑色点数之和。

【输出格式】

输出一行。如果小青鱼有可能投掷出三只骰子使得所有朝上的面中,红色的点数之和恰好为 A A A,而黑色的点数之和恰好为 B B B,则输出 Yes。否则输出 No

【样例解释】

在第一组样例中,其中一种合法的方案为 4 , 2 , 3 4, 2, 3 4,2,3

在第二组样例中,其中一种合法的方案为 1 , 1 , 1 1, 1, 1 1,1,1

题目描述

Dice are small, throwable objects with marked sides capable of landing in multiple positions. They are typically used to generate random values, especially in the context of tabletop games.

The most common dice are small cubes, with faces numbered from 1 1 1 to 6 6 6. Number n n n ( 1 ≤ n ≤ 6 1 \le n \le 6 1n6) is usually represented by a pattern of n n n round dots, known as pips. Moreover, the pips on the 1 1 1 and 4 4 4 faces are colored red, while those on the 2 2 2, 3 3 3, 5 5 5 and 6 6 6 faces are black.

Little Cyan Fish has three dice. One day, he threw them onto a table, and then observed the uppermost faces. He claimed that the total number of the red pips facing up was exactly A A A, and the total number of the black pips facing up was exactly B B B.

However, you find his claim doubtful. You want to verify whether it is possible to throw three dice such that the total number of red pips facing up is A A A, and the total number of black pips facing up is B B B.

输入格式

There is only one test case in each test file.

The first line of the input contains two integers A A A and B B B ( 0 ≤ A , B ≤ 100 0 \leq A,B \leq 100 0A,B100), indicating the total number of red pips facing up and the number of black pips facing up.

输出格式

Output one line. If it is possible for Little Cyan Fish to throw three dice such that the total number of red pips facing up is A A A, and the total number of black pips facing up is B B B output Yes. Otherwise output No.

样例 #1

样例输入 #1

4 5

样例输出 #1

Yes

样例 #2

样例输入 #2

3 0

样例输出 #2

Yes

样例 #3

样例输入 #3

1 2

样例输出 #3

No

提示说明

In the first example, one possible solution is 4 , 2 , 3 4, 2, 3 4,2,3.

In the second example, one possible solution is 1 , 1 , 1 1, 1, 1 1,1,1.

代码内容

// #include <iostream>
// #include <algorithm>
// #include <cstring>
// #include <stack>//栈
// #include <deque>//队列
// #include <queue>//堆/优先队列
// #include <map>//映射
// #include <unordered_map>//哈希表
// #include <vector>//容器,存数组的数,表数组的长度
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
ll col[7]={0,0,1,1,0,1,1};

int main()
{
    ll a,b;
    cin>>a>>b;
    
    for(ll i=1;i<=6;i++)
        for(ll j=1;j<=6;j++)
            for(ll k=1;k<=6;k++)
            {
                ll res[2]={0,0};
                res[col[i]]+=i;
                res[col[j]]+=j;
                res[col[k]]+=k;//三个骰子加对应颜色
                if(a==res[0]&&b==res[1])
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }

    cout<<"No"<<endl;
    return 0;
}
  • 9
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Pretty Boy Fox

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值