| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
按博弈公式来的同学注意精度float的精度不够,要用double,不然会悲剧的WA
#include <stdio.h>
#include <math.h>
double sq5 = sqrt(5);
int match(int a, int b){
int j = b - a;
int aj = floor(j * (sq5 + 1.0)/2.0);
if(aj == a)
return 1;
// printf("j = %d, aj = %d\n", j, aj);
return 0;
}
#define swap(a, b) \
{ \
int tm = (a); \
(a) = (b); \
(b) = tm; \
}
int main(){
int a, b;
while(scanf("%d%d", &a, &b) != EOF){
if(a > b)
swap(a, b);
if(match(a, b)){
printf("0\n");
}else{
printf("1\n");
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator