• Source
    1. #include <bits/stdc++.h>
    2. #include <numeric>
    3. #define REP(i, s, n) for (int i = s; i < n; ++i)
    4. #define rep(i, n) REP(i, 0, n)
    5. #define SORT(c) sort((c).begin(), (c).end())
    6. #define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
    7.  
    8. #define IINF INT_MAX
    9. #define LLINF LLONG_MAX
    10. #define DEBUG true
    11. #define LL long long
    12. #define Dev 1000000007
    13.  
    14. // sort(a.begin(), a.end(), std::greater<int>());
    15. using namespace std;
    16.  
    17. int main()
    18. {
    19. long long int n=0;
    20. long long int ch_num = 0;
    21. char ch[11] = {0};
    22. rep(i, 11) ch[i] = -1;
    23. cin >> n;
    24. int counter = 0;
    25. while (n >= ch_num)
    26. {
    27. int foo[3] = {0};
    28. ch[0]++;
    29. rep(i, 10)
    30. {
    31. if (ch[i] > 2)
    32. {
    33. ch[i] = 0;
    34. ch[i + 1]++;
    35. }
    36. }
    37. ch_num = 0;
    38. rep(i, 11)
    39. {
    40. if (ch[i] == 0)
    41. {
    42. ch_num += 3 * pow(10, i);
    43. foo[0] += 1;
    44. }
    45. if (ch[i] == 1)
    46. {
    47. ch_num += 5 * pow(10, i);
    48. foo[1] += 1;
    49. }
    50. if (ch[i] == 2)
    51. {
    52. ch_num += 7 * pow(10, i);
    53. foo[2] += 1;
    54. }
    55. }
    56. if (foo[0] > 0 && foo[1] > 0 && foo[2] > 0 &&n>=ch_num) //3,5,7があるか
    57. counter++;
    58. }
    59. cout << counter << endl;
    60. return 0;
    61. }
    62.