Language: C++

#include <iostream>
using namespace std;

uint64_t C[11][11] = {};

uint64_t combination(unsigned int n, unsigned int r) {
	if (C[n][r] == 0)
	{
		if (r * 2 > n) r = n - r;
		uint64_t dividend = 1;
		uint64_t divisor = 1;
		for (unsigned int i = 1; i <= r; ++i) {
			dividend *= (n - i + 1);
			divisor *= i;
		}
		C[n][r] = dividend / divisor;
	}
	return C[n][r];
}

uint64_t calc_2digit_count(int fig)
{
	// 桁数=figの数に対して2つの数による組み合わせ数を計算
	uint64_t calc2 = 0;

	for (int i = 1; i < fig; i++)
	{
		calc2 += combination(fig, i);
	}
	return calc2;
}

uint64_t calc_3digit_count(int fig)
{
	// 桁数=figの数に対して3つの数による組み合わせ数を計算
	uint64_t calc3 = 0;

	for (int i = 1; i < fig; i++)
	{
		for (int j = 1; j < fig - i; j++)
		{
			calc3 += combination(fig, i) *combination(fig - i, j);
		}
	}
	return calc3;
}

uint64_t GetMax753Number(uint64_t orig)
{
	int fig; // 桁数
	uint64_t ret = 0;
	uint64_t tmp = 0;
	int of = 0;

	fig = (int)log10((double)orig) + 1;

	for (int i = fig; i > 0; i--)
	{
		int tg = 0;
		if (of == 1)
		{
			tg = 7;
		}
		else
		{
			tg = (int)(orig / pow(10, i - 1)) % 10;
		}

		switch (tg)
		{
		case 0:
		case 1:
		case 2:
			tg = 0;
			of = 1;
			break;
		case 4:
			tg = 3;
			of = 1;
			break;
		case 6:
			tg = 5;
			of = 1;
			break;
		case 8:
		case 9:
			tg = 7;
			of = 1;
		}

		tmp = tmp * 10 + tg;
	}
//	cout << tmp << endl;

	fig = (int)log10((double)tmp) + 1;
	for (int i = 1; i <= fig; i++)
	{
		int tg = (int)(tmp / pow(10, i - 1)) % 10;

		if ((tg == 0) && (i !=fig))
		{
			int tg2 = (int)(tmp / pow(10, i)) % 10; //  1つ上の桁
			tg = 7;
			if (tg2 == 3)
			{
				tmp -= 3 * pow(10, i);
			}
			else if (tg2 > 3)
			{
				tmp -= 2 * pow(10, i);
			}
		}

		ret = ret + tg * pow(10, i - 1);
	}

	cout << ret << endl << endl;

	return(ret);
}

uint64_t Count753Num(uint64_t N, int fig, int f753, int oflg)
{
	uint64_t ret = 0;
	int tg;

	if (oflg == 1)
	{
		tg = 7;
	}
	else
	{
		tg = (int)(N / pow(10, fig - 1)) % 10;
	}

	for (int i = 3; i <= tg; i = i + 2)
	{
		int f753t = f753 | (int)pow(2, ((i - 1) / 2) - 1);
		if (fig == 1)
		{
			if (f753t == 7) ret++;
		}
		else
		{
			if (i < tg)
			{
				oflg = 1;
			}
			ret += Count753Num(N, fig - 1, f753t, oflg);
		}
	}

	return(ret);
}


int main()
{
	uint64_t N; // 入力された数
	int fig; // 桁数
	int figN753; // 桁数
	int f753 = 0; // 753の使用フラグ
	int tg;
	uint64_t N753; // Nを超えない753のいずれかで構築された数
	uint64_t Count753[11] = {};
	uint64_t Total753 = 0;

	cin >> N;

	fig = (int)log10((double)N) + 1;
//	cout << fig << endl;

	// 桁数-1までの753数の算出
	for (int i = 1; i < fig; i++)
	{
		Count753[i] = calc_3digit_count(i);
		Total753 += Count753[i];
//		cout << i << " " << Count753[i] << endl;
	}

	// 最上位の桁数で場合分け
	tg = (int)(N / pow(10, fig - 1));
	switch (tg)
	{
	case 1:
	case 2: // 1桁少ないの753数が対象
		break;
	case 4: // 3で始まる753数を追加
		Total753 += calc_3digit_count(fig) / 3;
		break;
	case 6: // 3と5で始まる753数を追加
		Total753 += calc_3digit_count(fig) * 2 / 3;
		break;
	case 8: // 当該桁数の753数を追加
	case 9:
		Total753 += calc_3digit_count(fig);
		break;

	case 3:
	case 5:
	case 7:
		N753 = GetMax753Number(N);
		figN753 = (int)log10((double)N753) + 1;
		Total753 += Count753Num(N753, figN753, f753, 0);
		break;
	}

	cout << Total753 << endl;
	return(0);

}

Compiler output:
a.cc:4:1: error: 'uint64_t' does not name a type
    4 | uint64_t C[11][11] = {};
      | ^~~~~~~~
a.cc:2:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    1 | #include <iostream>
  +++ |+#include <cstdint>
    2 | using namespace std;
a.cc:6:1: error: 'uint64_t' does not name a type
    6 | uint64_t combination(unsigned int n, unsigned int r) {
      | ^~~~~~~~
a.cc:6:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:21:1: error: 'uint64_t' does not name a type
   21 | uint64_t calc_2digit_count(int fig)
      | ^~~~~~~~
a.cc:21:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:33:1: error: 'uint64_t' does not name a type
   33 | uint64_t calc_3digit_count(int fig)
      | ^~~~~~~~
a.cc:33:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:48:1: error: 'uint64_t' does not name a type
   48 | uint64_t GetMax753Number(uint64_t orig)
      | ^~~~~~~~
a.cc:48:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:122:1: error: 'uint64_t' does not name a type
  122 | uint64_t Count753Num(uint64_t N, int fig, int f753, int oflg)
      | ^~~~~~~~
a.cc:122:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'int main()':
a.cc:159:9: error: 'uint64_t' was not declared in this scope
  159 |         uint64_t N; // 入力された数
      |         ^~~~~~~~
a.cc:159:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:164:17: error: expected ';' before 'N753'
  164 |         uint64_t N753; // Nを超えない753のいずれかで構築された数
      |                 ^~~~~
      |                 ;
a.cc:165:17: error: expected ';' before 'Count753'
  165 |         uint64_t Count753[11] = {};
      |                 ^~~~~~~~~
      |                 ;
a.cc:166:17: error: expected ';' before 'Total753'
  166 |         uint64_t Total753 = 0;
      |                 ^~~~~~~~~
      |                 ;
a.cc:168:16: error: 'N' was not declared in this scope
  168 |         cin >> N;
      |                ^
a.cc:170:20: error: 'log10' was not declared in this scope
  170 |         fig = (int)log10((double)N) + 1;
      |                    ^~~~~
a.cc:176:17: error: 'Count753' was not declared in this scope
  176 |                 Count753[i] = calc_3digit_count(i);
      |                 ^~~~~~~~
a.cc:176:31: error: 'calc_3digit_count' was not declared in this scope
  176 |                 Count753[i] = calc_3digit_count(i);
      |                               ^~~~~~~~~~~~~~~~~
a.cc:177:17: error: 'Total753' was not declared in this scope
  177 |                 Total753 += Count753[i];
      |                 ^~~~~~~~
a.cc:182:24: error: 'pow' was not declared in this scope
  182 |         tg = (int)(N / pow(10, fig - 1));
      |                        ^~~
a.cc:189:17: error: 'Total753' was not declared in this scope
  189 |                 Total753 += calc_3digit_count(fig) / 3;
      |                 ^~~~~~~~
a.cc:189:29: error: 'calc_3digit_count' was not declared in this scope
  189 |                 Total753 += calc_3digit_count(fig) / 3;
      |                             ^~~~~~~~~~~~~~~~~
a.cc:202:17: error: 'N753' was not declared in this scope; did you mean 'f753'?
  202 |                 N753 = GetMax753Number(N);
      |                 ^~~~
      |                 f753
a.cc:202:24: error: 'GetMax753Number' was not declared in this scope
  202 |                 N753 = GetMax753Number(N);
      |                        ^~~~~~~~~~~~~~~
a.cc:204:29: error: 'Count753Num' was not declared in this scope
  204 |                 Total753 += Count753Num(N753, figN753, f753, 0);
      |                             ^~~~~~~~~~~
a.cc:208:17: error: 'Total753' was not declared in this scope
  208 |         cout << Total753 << endl;
      |                 ^~~~~~~~