oj_11 [poj 1067]取石子游戏

来源:互联网 发布:淘宝装修神器书本 编辑:程序博客网 时间:2024/06/03 13:23

poj 1067

做法和ssn不一样因为 a<=i * (sqrt(5)+1)/2<b所以 a * e<=i< b *e             //e=(sqrt(5)-1)/2因为对于每一个a,b符合条件的i有且只有一个所以得出AC代码(压行技巧没ssn高超)
#include<cstdio>#include<cmath>#include<iostream>using namespace std;double e,d;int p,q,x;int main(){    freopen("data.txt","r",stdin);    freopen("1.txt","w",stdout);    e=(sqrt(5)-1)/2;    d=(sqrt(5)+1)/2;    while(scanf("%d%d",&p,&q)==2){        if(p==0&&q==0){            printf("0\n");            continue;        }        if(p>q)swap(p,q);        if((x=ceil(p*e))<q*e&&q==x+p&&floor(x*d)==p)printf("0\n");        else printf("1\n");    }}
0 0
原创粉丝点击