From 2384573091df2040d4f24ee7b09c079fc8113174 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 21 Nov 2021 18:24:12 +0800 Subject: [PATCH] =?UTF-8?q?P1980=20[NOIP2013=20=E6=99=AE=E5=8F=8A=E7=BB=84?= =?UTF-8?q?]=20=E8=AE=A1=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R63298328 --- Luogu/P1980/P1980.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Luogu/P1980/P1980.cpp diff --git a/Luogu/P1980/P1980.cpp b/Luogu/P1980/P1980.cpp new file mode 100644 index 00000000..6ddae879 --- /dev/null +++ b/Luogu/P1980/P1980.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int n, x, ans; + +int cntx(int num) { + int res = 0; + while (num) { + res += num % 10 == x; + num /= 10; + } + return res; +} + +int main() { + cin >> n >> x; + for (int i = 1; i <= n; i++) { + ans += cntx(i); + } + cout << ans << endl; + return 0; +}