题解 | #挑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");
}
}