题解 | #挑7#
挑7
http://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b
Java 实现 挑7 算法
import java.util.*; import java.lang.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNext()) { int n = sc.nextInt(); List<Integer> list = new ArrayList<Integer>(); String str = ""; for(int i = 1 ;i<=n;i++) { str = String.valueOf(i); if(str.contains("7") || i%7 == 0){ list.add(i); } } System.out.println(list.size()); } } }