poj 1067 威佐夫博奕

http://poj.org/problem?id=1067

分析:威佐夫博奕模版题

对于(n,m),int k=m-n;如果int tmp=double(k*(1.0+sqrt(5.0))/2.0)==n,那么(n,m)肯定是奇异局势,也就是必败点了

View Code
// I'm lanjiangzhou
//C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
//C++
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <vector>
#include <deque>
#include <set>
using namespace std;

//*************************OUTPUT*************************
#ifdef WIN32
#define INT64 "%I64d"
#define UINT64 "%I64u"
#else
#define INT64 "%lld"
#define UINT64 "%llu"
#endif

//**************************CONSTANT***********************
#define INF 0x3f3f3f3f

// aply for the memory of the stack
//#pragma comment (linker, "/STACK:1024000000,1024000000")
//end


int main(){
    int n,m;
    double x;
    x=(double)((1+sqrt(5.0))/2);
    while(scanf("%d%d",&n,&m)!=EOF){
        //假定n<m
        if(n>=m){
            int t=n;
            n=m;
            m=t;
            //printf("n=%d m=%d\n",n,m);
        }
        int k=m-n;
        int ak=(int)(x*k);
        if(ak==n)printf("0\n");
        else printf("1\n");
    }
    return 0;
}

 

posted @ 2013-04-12 22:01  南下的小程序员  阅读(141)  评论(0编辑  收藏  举报