打表,发现规律,有周期性
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
#define ll long long
#define maxn 100005
int num[30] = { 1, 2, 4, 8, 16, 23, 46, 29, 58, 116, 223, 446, 289, 578, 1156, 1223, 2446, 2489, 4789, 5789, 11578, 12356, 12247, 24449, 48889, 77789, 155578, 111356, 122227, 244445 };
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//48889 -> 24
ll n;
scanf("%I64d", &n);
n--;
if (n >= 30)
{
n = (n - 30) % 6 + 24;
}
printf("%d\n", num[n]);
//system("pause");
//while (1);
return 0;
}