zoukankan      html  css  js  c++  java
  • classic problem: 100 horse and 100 dan

    public class HorseDan {

        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub

            // 100 horses, 100 dan
            // big horse 3, mid 2, small 1/2
           
            int totalWays = 0;
           
            for (int i=1; i<33; i++) {
                for (int j=1; j<50; j++) {
                    int k = 100 - i - j;
                    if (k%2 == 0) {
                        if (i*3 + j*2 + k/2 == 100) {
                            totalWays++;
                            System.out.print("big: " + i + ",");
                            System.out.print("mid: " + j + ",");
                            System.out.print("small: " + k);
                            System.out.println();
                        }   
                    }
                }   
            }

      
            System.out.println("totalWays: " + totalWays);


        }
    }

  • 相关阅读:
    Hadoop下面WordCount运行详解
    ubuntu下hadoop环境配置
    ubuntu下的jdk安装
    ASP.NET MVC4中用 BundleCollection使用问题手记
    Lab6: Paxos
    java命令行操作
    Mesos 入门教程
    Docker background
    找实习的日子
    九度 1557:和谐答案 (LIS 变形)
  • 原文地址:https://www.cnblogs.com/tiechui/p/1898835.html
Copyright © 2011-2022 走看看