题解 | 记数问题
记数问题
https://www.nowcoder.com/practice/28b2d9f2bf2c48de94a1297ed90e1732
package main
import (
"fmt"
"strconv"
"strings"
)
func main() {
var n, x int
fmt.Scan(&n, &x)
count := 0
for i := 1; i <= n; i++ {
for j := 0; j < len(strconv.Itoa(i)); j++ {
if strings.Contains(string(strconv.Itoa(i)[j]), strconv.Itoa(x)) {
count += 1
}
}
}
fmt.Print(count)
}
