diff --git a/Luogu/P1179/P1179.cpp b/Luogu/P1179/P1179.cpp new file mode 100644 index 00000000..50e7724a --- /dev/null +++ b/Luogu/P1179/P1179.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +int l, r, ans; + +int cnt2(int x) { + int res = 0; + while (x) { + res += x % 10 == 2; + x /= 10; + } + return res; +} + +int main() { + cin >> l >> r; + for (int i = l; i <= r; i++) { + ans += cnt2(i); + } + cout << ans << endl; + return 0; +}