题解 | #百万富翁问题#写个for循环就行

百万富翁问题

https://www.nowcoder.com/practice/9fe25b6cf93e46dcb09ba67aeef2c4cc

public class Main {
    public static void main(String[] args) {
        int wealthy = 0, stranger = 0;
        for (int i = 0; i < 30; i++) {
            wealthy += 10;
            stranger += (int) Math.pow(2, i);
        }
        System.out.println(wealthy + " " + stranger);
    }
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-04 14:35
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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