zoukankan      html  css  js  c++  java
  • 【原创】分鱼问题

    题目描述:

    A,B,C,D,E五个人捕鱼,第一天太累了回去就睡觉了,第二天早上A醒来把鱼分成5份然后扔了一条,拿走自己的一份,B同样把鱼分成五份,扔一条多余的,自己拿走自己的那份,然后C,D,E做了同样的事。求鱼共有多条?

     1 import static java.lang.System.out;
     2 
     3 public class fish {
     4 
     5      static void fish_()
     6     {
     7          float sum;//E拿到的鱼1条
     8          int x = 1,i;
     9             while(true)
    10             {
    11                     sum = x * 4;
    12                     for(i = 0; i < 5; i++)
    13                     {
    14                           sum = (float) (sum * 5.0/4.0);
    15                           if((sum - (int)sum) != 0)
    16                           {
    17                                   x = x + 1;
    18                                   break;
    19                           }
    20                           sum = sum + 1; 
    21                     }
    22                     if(i == 5)
    23                     {
    24                     out.println((int)sum);
    25                     break;
    26                     }
    27             }
    28 
    29     }
    30     public static void main(String []args)
    31     {
    32         fish_();
    33     }
    34 }
  • 相关阅读:
    Volume 6. Mathematical Concepts and Methods
    git帮助网址
    ubuntu 下安装wine
    ubuntu 通过ppa源安装mysql5.6
    ubuntu qq安装
    ubuntu14.04 fcitx安装
    language support图标消失
    ubuntu root用户登陆
    ubuntu 安装codeblocks13.12
    ubuntu tomcat自启动
  • 原文地址:https://www.cnblogs.com/xiawen/p/3038501.html
Copyright © 2011-2022 走看看