zoukankan      html  css  js  c++  java
  • 坑爹的水题之“元芳你怎么看”

    题目大意:

      一些人分银子,如果每个人分x两,那么还有y两分不出去;如果每个人分i 两的话那么还差 j 两银子。问你输入x,y,i,j 四个整数,能否成立。

    解题思路:

      啥叫思路,我已经WA了5发,还是看不出哪里错了,就特么很尴尬。

      题目链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1800

    AC代码:

      

     1 #include <stdio.h>
     2 int main()
     3 {
     4     double x, y, i, j;
     5     while(scanf("%lf%lf%lf%lf",&x,&y,&i,&j)!=EOF)
     6     {
     7         double n=(y+j)/(i-x);
     8         double m=n-(int)n;
     9         if (n>0 && m==0)
    10            printf ("He is right
    ");
    11         else
    12            printf ("Back to the adult, it surely has something
    ");
    13     }
    14     return 0;
    15 }

    我的代码:

     1 #include <stdio.h>
     2 int main()
     3 {
     4     int x, y, i, j;
     5     while(scanf("%d%d%d%d",&x,&y,&i,&j)!=EOF)
     6     {
     7         int flag = 1;
     8         double p = -1.0;
     9         if((i - x) == 0)
    10         {
    11             flag = 0;
    12         }
    13         else
    14         {
    15             p = 1.0 *((y+j)/(i-x));
    16         }
    17         double t = p - (int)p;
    18         if (p > 0 && t == 0.0 && flag == 1)
    19             printf ("He is right
    ");
    20         else
    21             printf ("Back to the adult, it surely has something
    ");
    22     }
    23     return 0;

    我也是醉了,这么相似的代码竟然是错的 =  =!

  • 相关阅读:
    CQOI2009中位数图
    CQOI2011分金币&HAOI2008糖果传递
    SCOI2010游戏
    JSOI2007建筑抢修
    HNOI2008明明的烦恼
    SCOI2009生日快乐
    (22/24) webpack实战技巧:静态资源集中输出
    (22/24) webpack实战技巧:静态资源集中输出
    [mysql]linux mysql 读写分离
    [mysql]linux mysql 读写分离
  • 原文地址:https://www.cnblogs.com/love-fromAtoZ/p/7528272.html
Copyright © 2011-2022 走看看