diff options
author | crupest <crupest@outlook.com> | 2021-03-23 19:18:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-03-23 19:18:25 +0800 |
commit | 463230ecaa39fc53829cdbef53150562df4ea414 (patch) | |
tree | 6548661ae5cbddab35c9c128ff23b0602749b2a5 /acwing | |
parent | 426ed9924c1be56b27bb760f326843ee958d46c9 (diff) | |
download | solutions-463230ecaa39fc53829cdbef53150562df4ea414.tar.gz solutions-463230ecaa39fc53829cdbef53150562df4ea414.tar.bz2 solutions-463230ecaa39fc53829cdbef53150562df4ea414.zip |
Add acwing 1245.
Diffstat (limited to 'acwing')
-rw-r--r-- | acwing/1245.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/acwing/1245.cpp b/acwing/1245.cpp new file mode 100644 index 0000000..ba51a8f --- /dev/null +++ b/acwing/1245.cpp @@ -0,0 +1,29 @@ +#include <iostream>
+
+bool check(int n) {
+ while (n != 0) {
+ int k = n % 10;
+ if (k == 2 || k == 0 || k == 1 || k == 9) {
+ return true;
+ }
+ n /= 10;
+ }
+ return false;
+}
+
+int main() {
+ int n;
+ std::cin >> n;
+
+ long long sum;
+
+ for (int i = 1; i <= n; i++) {
+ if (check(i)) {
+ sum += i;
+ }
+ }
+
+ std::cout << sum;
+
+ return 0;
+}
|