提交时间:2025-12-26 15:42:13
运行 ID: 78371
#include <iostream> #include <vector> int countDigitInFactorial(int n, int digit) { int count = 0; for (int i = 1; i <= n; ++i) { int num = i; while (num > 0) { if (num % 10 == digit) ++count; num /= 10; } } return count; } int main() { int t; std::cin >> t; while (t--) { int n, digit; std::cin >> n >> digit; std::cout << countDigitInFactorial(n, digit) << std::endl; } return 0; }