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);


        }
    }

  • 相关阅读:
    fastjson 使用方法
    算法
    SHA算法
    MD5算法
    kindle推送服务
    DLL劫持
    Hook编程
    Hook技术
    权限验证
    虚拟机
  • 原文地址:https://www.cnblogs.com/tiechui/p/1898835.html
Copyright © 2011-2022 走看看