Gym-100502D Dice Game

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Richie_ll/article/details/60469848

题目链接:https://vjudge.net/problem/Gym-100502D
题意:输入有两行,每行四个数
解析:比赛的时候没有怎么看题,直接看的样例,以为是四个数字相加比大小然后输出结果,不过比完赛以后,听队友说好像是求期望,不过期望的形式和四个数相加没区别

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int maxn = 1000+100;
int main()
{
    int sum1 = 0,sum2 = 0;
    int x;
    for(int i=0;i<4;i++)
    {
        scanf("%d",&x);
        sum1+=x;
    }
    for(int i=0;i<4;i++)
    {
        scanf("%d",&x);
        sum2 += x;
    }
    if(sum1<sum2)
        puts("Emma");
    else if(sum1>sum2)
        puts("Gunnar");
    else
        puts("Tie");

    return 0;
}
阅读更多
换一批

Dice Matrix

04-18

Dice Matrix is a puzzle made of several dice. The rules of this puzzle are as follows.nnDice with six faces as shown in following figure are used in the puzzle.nThe direction of each die is also shown as in the following figure initially.nnnThe dice are arranged in n rows and m columns. The following figure shows a 3 * 3 dice matrix.nnnEach time you can select a row or a column to rotate.nYou can rotate any angle you like.nAll the dice in that row/column must be rotated the same angle in the same direction.nThe dice can only be rotated perpendicular to the row/column. You can't rotate the dice along the row/column. (You can see the sample for more details.)nnnGiven the target top faces of a dice matrix, your task is to find the minimum steps from the initial configuration to the target one.nInputnnStandard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 2000) which is the number of test cases. And it will be followed by T consecutive test cases.nnThe first line of each test case contains two integers n and m (1 <= n, m <=4, n * m <= 10), indicating the number of rows and the number of columns of the dice matrix. The next n lines will contain m integers separated by one space each, which are between 1 and 6 inclusive, indicating the target top faces of the dice matrix.nnOutputnnIf you can make it to the target result in 5 steps, print the number of minimum steps in one line; otherwise print the word "Impossible" on a single line.nnSample Inputnn5n2 2n2 1n2 1n2 2n6 1n6 1n1 2n2 2n1 1n1n2 2n1 3n2 4nSample Outputnn1n1n2n0nImpossible

Dice Contest

08-03

DescriptionnnEveryone loves gambling in the Dicent City. Every Saturday the whole community meets to attend a dice contest. They started a few years ago with a classic six-sided die with 1 to 6 dots displayed on the sides and had a lot of fun. nnnHowever they soon got bored and that's why more sophisticated dice are in use nowadays. They put a sticker on each side and write a positive integer on each sticker. nnThe contest is run on a strip divided into squares in a chessboard-like manner. The strip is 4 squares wide and infinite to the left and to the right (is anyone going to say it can't exist in the real world, huh?). The rows of the strip are numbered from 1 to 4 from the bottom to the top and the columns are numbered by consecutive integers from the left to the right. Each square is identified by a pair (x,y) where x is a column number and y is a row number. nnThe game begins with a die placed on a square chosen be a contest committee with one-dot side on the top and two-dots side facing the player. To move the die the player must roll the die over an edge to an adjacent (either horizontally or vertically) square. The number displayed on the top of the die after a roll is the cost of the move. The goal of the game is to roll the die from the starting square to the selected target square so that the sum of costs of all moves is minimal. nnTask nWrite a program that: nnreads the description of a die, a starting square and a target square, ncomputes the minimal cost of rolling the die from the starting square to the target square, nwrites the result. nNote: all teams participating in the contest received dice from the organisers. nInputnnThe first line of the input contains six integers l1, l2, l3, l4, l5, l6 (1 < = li < = 50) separated by single spaces. Integer li is the number written on a side having originally i dots. The second line of the input contains four integers x1, y1, x2, y2 ( -109 < = x1, x2 < = 109, 1 <= y1, y2 < = 4) separated by single spaces. Integers x1, y1 are the column and the row number of the starting square respectively. Integers x2, y2 are the column and the row number of the target square respectively.nOutputnnThe first and the only line of the output should contain the minimal cost of rolling the die from the starting square to the target square.nSample Inputnn1 2 8 3 1 4n-1 1 0 2nSample Outputnn7

没有更多推荐了,返回首页