hdu2177----(2 piles) Stone game

Source: Internet
Author: User

Witzov Game game Theory Direct simulation can be worth mentioning is that the problem almost all the online problems are not considered only from the small heap to get the situation, so in similar 19 20 when the data appears, they are wrong only output 1 2 and not 12 20

1#include <cstdio>2 3#include <cmath>4 5#include <map>6 7#include <string.h>8 9 #defineINF 0x3f3f3f3fTen  One Const intmaxn=1000000; A  - using namespacestd; -  the intb; -  - BOOLJudgeintAintb) { -  +    returna== (int) ((b-a) * (sqrt (5.0)+1)/2); - } +  A intMain () at { -      while(SCANF ("%d%d", &a,&b)!=eof&& (a| |b)) { -map<int,int>Flag; -         if(judge (A, B)) { -printf"0\n"); -}Else { inprintf"1\n"); -            for(intI=0, j=0; i<=a;i++){ to                 if(!flag[i]&&!flag[i+J]) { +                //printf ("%d%d\n", i,i+j); -flag[i]=flag[i+j]=1; the                 if(a-i==b-i-j&&a>i&&b>i+j) *printf"%d%d\n", i,i+j); $                 /*else if ((a==i+j&&b>i) | | | (a==i&&i+j<b) | | (B==i+j&&a>i)) printf ("%d%d\n", i,i+j);*/Panax NotoginsengJ + +; -                 } the         } + flag.clear (); A          for(intI=0, j=0; i<=a;i++){ the                 if(!flag[i]&&!flag[i+J]) { +                //printf ("%d%d\n", i,i+j); -flag[i]=flag[i+j]=1; $                /*if (a-i==b-i-j&&a>i&&b>i+j) $ printf ("%d%d\n", i,i+j);*/ -                 if((a==i+j&&b>i) | | (a==i&&i+j<b) | | (B==i+j&&a>i)) printf"%d%d\n", i,i+j); -J + +; the                 } -         }Wuyi         } the     } -     return 0; Wu}
View Code

This question reminds us, on the Internet to see the problem, no matter how big Daniel wrote, also must bring their own thinking.

hdu2177----(2 piles) Stone 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.