坑爹的水题之“元芳你怎么看”

题目大意:

  一些人分银子,如果每个人分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\n");
11         else
12            printf ("Back to the adult, it surely has something\n");
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\n");
20         else
21             printf ("Back to the adult, it surely has something\n");
22     }
23     return 0;

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

转载于:https://www.cnblogs.com/love-fromAtoZ/p/7528272.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值