CSU 1577 Dice Game (game)

Source: Internet
Author: User

Test instructions: There are two people each can sprinkle two dice to give the maximum and minimum value of each dice

Who spread out the numbers and the big who wins

Idea: Calculate the possible value intervals for two people because they are evenly distributed

So the two overlapping interval winning the same so just calculate who wins the interval large can produce results

#include <cstdio> #include <iostream> #include <cstring> #include <cmath> #include <queue > #include <stack> #include <vector> #include <stdlib.h> #include <algorithm>using namespace Std;int Dir4[][2]={{0,1},{1,0},{0,-1},{-1,0}};int dir8[][2]={{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-    1,1}};int Main () {int a1,b1,a2,b2,a1,b1,a2,b2; while (scanf ("%d%d%d%d%d%d%d%d", &AMP;A1,&AMP;B1,&AMP;A2,&AMP;B2,&AMP;A1,&AMP;B1,&AMP;A2,&AMP;B2)!=EOF) {int Minn        1=A1+A2,MAXN1=B1+B2,MINN2=A1+A2,MAXN2=B1+B2;        printf ("%d%d%d", minn1,maxn1,minn2,maxn2);            if (maxn2<=minn1 | | maxn1<=minn2) {//printf ("1...\n");            if (maxn2<=minn1) printf ("gunnar\n");        else printf ("emma\n");            } else if (minn1==minn2 && maxn1==maxn2) {//printf ("2...\n");            printf ("tie\n");        Continue } else if ((minn2<=maxn1&&minn2>=minn1&&AMP;MAXN2&GT;=MAXN1) | |        (MINN1&LT;=MAXN2&AMP;&AMP;MINN2&LT;=MINN1&AMP;&AMP;MAXN1&GT;=MAXN2))            {//printf ("3...\n");            if (MINN2&LT;=MAXN1&AMP;&AMP;MINN2&GT;=MINN1&AMP;&AMP;MAXN2&GT;=MAXN1) printf ("emma\n");        else printf ("gunnar\n"); } else if ((minn1>=minn2&&maxn2>=maxn1) | | |        (MINN2&GT;=MINN1&AMP;&AMP;MAXN2&LT;=MAXN1))            {//printf ("%d%d%d", minn1,maxn1,minn2,maxn2);                if (minn1>=minn2&&maxn2>=maxn1) {int len1=minn1-minn2;                int len2=maxn2-maxn1;                if (LEN2&GT;LEN1) printf ("emma\n");                else if (len1==len2) printf ("tie\n");            else printf ("gunnar\n");                } else {int len1=minn2-minn1;                int len2=maxn1-maxn2;                if (LEN2&GT;LEN1) printf ("gunnar\n");                else if (len1==len2) printf ("tie\n");       else printf ("emma\n");     }}} return 0;} 

  

CSU 1577 Dice Game (game)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.