Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- constexpr int f[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
- bool ok(int n) {
- int b = n;
- while (n) {
- b -= f[n % 10];
- n /= 10;
- }
- return !b;
- }
- signed main() {
- ios::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- int64_t s = 0;
- // do 40585 pa ke zakoci, najbolje samo soberi gi dvata broja lol
- for (int i = 3; i < 40586; i++) {
- if (ok(i)) {
- s += i;
- cerr << i << '\n';
- }
- }
- cout << s;
- }
Advertisement
Add Comment
Please, Sign In to add comment