zoukankan      html  css  js  c++  java
  • 穷举 百鸡百钱

     static void Main(string[] args)
            {
                while (true)
                {
                  
                    int n = 0;
                    for (int g = 1; g*2 <=100; g++)
                    {
                        for (int m = 1; m*1 <=100; m++)
                        {
                            for (int x = 1; x*0.5 <=100; x++)
                            {
                                if(g*2+m*1+x*0.5==100&&g+m+x==100)
                                {
                                    Console.WriteLine(g+"只公鸡"+m+"只母鸡"+x+"只小鸡");
                                   n++;
                                }
                            }
                        }
                    }
                    Console.WriteLine("共有"+n+"种可能性");
                    Console.ReadLine();
                }
            }

  • 相关阅读:
    1. 加载文件的方法
    9. 位运算符
    8. 条件(条目,三元)运算符
    3. PHP比较运算符
    hdu3336 Count the string
    Codeforces Round #228 (Div. 2)
    hdu4288 Coder(线段树单点更新)
    hdu2852 KiKi's K-Number
    poj1195
    poj2299
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4387970.html
Copyright © 2011-2022 走看看