题解 | #百钱买百鸡问题#

百钱买百鸡问题

http://www.nowcoder.com/practice/74c493f094304ea2bda37d0dc40dc85b

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.next();
            if(s.matches("^-?[1-9]\\d*$")){
                int sum = 100;
                int sCount = 100;
                int xConut = 0;
                for (int gCount = 0; gCount < 20; gCount++) {
                    for (int mCount = 0; mCount < 35; mCount++) {
                        xConut = sCount - gCount - mCount;
                        if((xConut % 3 == 0) && ((5 * gCount + 3 * mCount + xConut / 3) == sum)){
                            System.out.println(gCount + " " + mCount + " " + xConut);
                        }else {
                            continue;
                        }
                    }
                }
            }
        }
    }
}
全部评论

相关推荐

身边有人上海、深圳&nbsp;6、7k&nbsp;都去了,真就带薪上班了。
小浪_coder:深圳除了一些计算机,UI设计,金融类等一些可以月薪过万的工作之外, 认识很多朋友做运营,营销,文员的工作, 月薪基本都在4-6K左右,还有大把人在干
点赞 评论 收藏
分享
深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务