题解 | #挑7#

挑7

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

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int input = scanner.nextInt();
        int count = 0 ;
        for (int i = 1; i <= input; i++) {
            if (i%7==0 || i%10==7 || i/10%10==7 || i/100%10==7 || i/1000%10==7)
                count++;
        }
        System.out.println(count);
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务