题解 | #挑7#

挑7

http://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.valueOf(scan.nextLine().trim());
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 7 == 0 || isContains(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
    public static boolean isContains(int num) {
        String str = String.valueOf(num);
        return str.contains("7");
    }
}
全部评论
该牛油正在参与牛客写题解薅羊毛的活动,牛币,周边,京东卡超多奖品放送,活动进入倒计时!快来捡漏啦https://www.nowcoder.com/discuss/888949?source_id=profile_create_nctrack&channel=-1
点赞 回复 分享
发布于 2022-04-27 11:44

相关推荐

06-27 15:29
门头沟学院 Java
点赞 评论 收藏
分享
Rena1ssanc...:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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