uva13130 Cacho

uva13130

uDebug13130

题意说是在玻利维亚有种掷骰子的游戏Cacho很受欢迎,而5颗骰子投掷出的结果,有一种情况叫做escala,即满足色子的结果是1,2,3,4,5或者2,3,4,5,6或1,3,4,5,6。本题中会给出每次掷骰子的结果,要求判断该结果是否是escala(其中1,3,4,5,6这种情况在本题中还不用考虑)

所以题目很简单,可以考虑字符串比较,也可以逐个计算比较。

python版本AC代码

testcase = int(input())
while testcase > 0:
	testcase -= 1
	dice = list(map(int,input().split()))
	flag = 1
	for i in range(4):
		if dice[i+1] != dice[i]+1:
			flag = 0
			break
	if flag == 1:
		print("Y")
	else:
		print("N") 

C++版本AC代码

#include <iostream>
#include<cstdio>
using namespace std;

//#define ZANGFONG
int dice[5];

int main()
{
    #ifdef ZANGFONG
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif // ZANGFONG

    int n;
    int i,j;
    int flag;
    scanf("%d\n",&n);

    for(i = 0; i < n; i++)
    {
        for(j = 0; j < 5; j++) scanf("%d",&dice[j]);
        getchar();
        flag = 1;
        for(j = 0; j < 4; j++)
        {
            if(dice[j+1] != dice[j]+1)
            {
                flag = 0;
                break;

            }
        }
        if(flag) printf("Y\n");
        else printf("N\n");

    }

    return 0;
}

猜你喜欢

转载自blog.csdn.net/zangfong/article/details/85206311
今日推荐