
首先有一个规律:当一个数字归位的时候,所有数字都会归位。
因此只需要模拟一个数字就可以了。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; int n; int main()
{
while (~scanf("%d", &n))
{
int ans = ;
int now = ; while ()
{
if (now <= n) now = now * ;
else now = * (now - n) - ;
ans++;
if (now == ) break;
} printf("%d\n", ans);
}
return ;
}