题解 | #[NOIP2010]数字统计#
[NOIP2010]数字统计
http://www.nowcoder.com/practice/179d9754eeaf48a1b9a49dc1d438525a
int main() {
int l, r, count = 0;
scanf("%d %d", &l, &r);
for (int i = l; i <= r; i++) {
int val = i;
while (val) {
if (val % 10 == 2) count++;
val /= 10;
}
}
printf("%d", count);
return 0;
}