CCF 201912-1 报数 (100分)Java

目前官网题目还没有公布,先把代码贴上

import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        new Main().run();
    }
    
    public void run() {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] people = new int[4];
        
        for(int i = 0; i < n; i++) {
            if((i+1) % 7 == 0 || String.valueOf(i+1).contains("7")) {
                people[i%4] ++;
                n++;
            }
        }
        
        for(int i = 0; i < 4; i++) {
            System.out.println(people[i]);
        }
    }

}
posted @ 2019-12-16 21:07  【展翅翱翔】  阅读(341)  评论(0编辑  收藏  举报