"hdu3544" Alice ' s Game

Source: Internet
Author: User

For a piece of n*m chocolate, Alice can only cut vertically, cut into a*m and b*m, and a+b=n,bob can only be cut into the cross, only into A*n and B*n, and a+b=m.

For n*n of this kind of chocolate, who first cut the first knife, directly let the other side has the opportunity to cut two knives, so Alice could not cut this chocolate, can directly ignore this.

After a person will try to choose the former one cut after a small piece of cut.

#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #include <cmath>using namespaceStd;typedefLong LongLL;intN,T;LL x,Y;intMain(){scanf("%d",&T); for (intI=1;I<=T;I++) {scanf("%d",&N);LL K1=0,K2=0; while (N--) {scanf("%lld%lld",&X,&Y); while (X>1&&Y>1)X>>=1,Y>>=1,K1++,K2++;if (X==1)K2+=Y-1;ElseK1+=X-1; }if (K1<=K2)Printf("Case%d:bob\n",I);ElsePrintf("Case%d:alice\n",I); }return0;}

"hdu3544" Alice ' s 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.