fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define ld long double
  4. #define nl "\n"
  5. #define OO 0x3f3f3f3f
  6. using namespace std;
  7. void ta2to2a()
  8. {
  9. ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr);
  10. #ifndef ONLINE_JUDGE
  11. freopen("input.txt", "r", stdin);
  12. freopen("output.txt", "w", stdout);
  13. #endif
  14. }
  15. int n;
  16. ll shichiGoSan(ll num, bool three, bool five, bool seven)
  17. {
  18. ll ans = 0;
  19. if (num > n)
  20. {
  21. return 0;
  22. }
  23. else if (num <= n && three && five && seven)
  24. {
  25. return 1;
  26. }
  27. ans += shichiGoSan(num * 10 + 3, true, five, seven) + shichiGoSan(num * 10 + 5, three, true, seven) + shichiGoSan(num * 10 + 7, three, five, true);
  28. return ans;
  29. }
  30. void solve()
  31. {
  32. cin >> n;
  33. cout << shichiGoSan(0, false, false, false);
  34. }
  35. int main()
  36. {
  37. ta2to2a();
  38. int t = 1;
  39. // cin >> t;
  40. while (t--)
  41. {
  42. solve();
  43. }
  44. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty