您的位置:首页 > 其它

男生女生配(抽屉原理)

2013-01-29 22:00 232 查看
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1470&cid=1142

View Code

#include<stdio.h>
int main()
{
int a, b, c, d, e, x, y;
int ming, maxg;
while(scanf("%d %d %d %d %d", &a, &b, &c, &d, &e))
{
if(a==0&&b==0&&c==0&&d==0&&e==0)break;
if(c < 0)
ming = 0;
else
ming = c * b + 1;
maxg = d - e;
if(e <= 0)
x = y = 0;
else
x = a - maxg;
y = a - ming;
if(x > y)
printf("%d\n",-1);
else
printf("%d %d\n",x,y);
}
return 0;
}


总结: 注意细节; 讨论各种可能出现的情况

测试数据如下:

20 5 -1 1 1
20 5 -1 20 1
20 5 1 20 1
21 5 4 20 1
21 5 4 1 0
21 5 4 5 1
21 5 5 5 1
-10 5 4 5 4
10 5 4 3 1
55 4 2 10 1
10 1 11 5 1
1 1 0 0 0
1 1 -1 0 0
0 1 -1 0 0
0 0 0 0 0
/////////////////
20 20
1 20
1 14
-1
0 0
-1
-1
-1
-1
46 46
-1
0 0
0 1
0 0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: