problemcutter

导航

SPOJ Problem 7424:Girls and Boys

已知男生和女生的人数,将男生和女生互相穿插,要求当连续的同性别人数最少时最多的同性别连续人数。

论bool()的妙用。。

#include<cstdio>
#define max(a,b)a>b?a:b
int x,y,s;
int main(){
    while(scanf("%d%d",&x,&y)&&(x+y!=-2)){
        s=max(y/(x+1)+bool(y%(x+1)),x/(y+1)+bool(x%(y+1)));
        printf("%d\n",s);
    }
}

 

posted on 2015-03-07 10:17  problemcutter  阅读(103)  评论(0)    收藏  举报