题解 | #[NOIP2013]记数问题#
[NOIP2013]记数问题
http://www.nowcoder.com/practice/28b2d9f2bf2c48de94a1297ed90e1732
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x=sc.nextInt(); int ans=0; for(int i=1;i<=n;i++) { int k=i; while(k!=0) { int temp=k%10; if(temp==x) { ans++; } k/=10; } } System.out.println(ans); } }