"Huawei OJ" "047-hundred money buy hundred chicken problem"

Source: Internet
Author: User

"Huawei OJ" "Algorithm Total chapter" "Huawei OJ" "047-hundred money buy Hundred chicken Problem" "Project Download" topic description
公元前五世纪,我国古代数学家张丘建在《算经》一书中提出了“百鸡问题”:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何? 详细描述: 接口说明 原型: int getResult()
Enter a description
Output description
list  鸡翁、鸡母、鸡雏组合的列表
Input example
1
Output example
0 25 754 18 788 11 8112 4 84
Algorithm implementation
ImportJava.util.Scanner;/** * Author: Wang Junshu * date:2015-12-25 08:15 * declaration:all rights Reserved!!! */ Public  class Main {     Public Static void Main(string[] args) {//scanner Scanner = new Scanner (system.in);Scanner Scanner =NewScanner (Main.class.getClassLoader (). getResourceAsStream ("Data.txt")); while(Scanner.hasnext ())            {Scanner.nextline ();        System.out.print (GetResult ());    } scanner.close (); }/** * Chicken Weng (x), chicken Mother (y), chickens (z) problem is to ask for 5x + 3y+ Z/3 and all possible solutions for x + y + z * * @return  */     Public StaticStringGetResult() {StringBuilder builder =NewStringBuilder (); for(intx =0; X <= -; X + +) { for(inty =0; Y <= --X; y++) {intz = --X-y;if(Z%3==0&& -==5* x +3* y + z/3) {builder.append (x). Append ("'). Append (y). Append ("'). Append (z). Append (' \ n '); }            }        }returnBuilder.tostring (); }}

"Huawei OJ" "047-hundred money buy hundred chicken problem"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.