zoukankan      html  css  js  c++  java
  • 男生女生配(抽屉原理)

    http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=1470&cid=1142

    View Code
     1 #include<stdio.h>
     2 int main()
     3 {
     4     int a, b, c, d, e, x, y;
     5     int ming, maxg;
     6     while(scanf("%d %d %d %d %d", &a, &b, &c, &d, &e))
     7     {
     8         if(a==0&&b==0&&c==0&&d==0&&e==0)break;
     9         if(c < 0)
    10             ming = 0;
    11         else
    12             ming = c * b + 1;
    13         maxg = d - e;
    14         if(e <= 0)
    15             x = y = 0;
    16         else
    17             x = a - maxg;
    18             y = a - ming;
    19         if(x > y)
    20             printf("%d\n",-1);
    21         else
    22             printf("%d %d\n",x,y);
    23     }
    24     return 0;
    25 }

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

    测试数据如下:

    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

  • 相关阅读:
    POJ 2209
    POJ 2196
    POJ 2215
    POJ 2192
    POJ 2195
    POJ 2181
    POJ 2182
    POJ 2159
    POJ 2153
    字符设备驱动 —— 字符设备驱动框架
  • 原文地址:https://www.cnblogs.com/yelan/p/2882085.html
Copyright © 2011-2022 走看看