Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- using namespace std;
- const int MAX=1000006;
- int dist[MAX];
- bool vis[MAX];
- void prep(int num,int ndis)
- {
- dist[num]=ndis;
- if ((num-1)%3 == 0 && num>4 && ((num-1)/3)%2==1 && !vis[(num-1)/3])
- {
- vis[(num-1)/3]=1;
- prep((num-1)/3,ndis+1);
- }
- if ((num*2)<MAX && !vis[num*2])
- {
- vis[num*2]=1;
- prep(num*2,ndis+1);
- }
- }
- int main()
- {
- int a,b,cmax;
- prep(1,1);
- while (0<scanf("%d%d",&a,&b))
- {
- cmax=0;
- for (int i=a;i<=b;++i)
- if (cmax<dist[i])
- cmax=dist[i];
- printf("%d %d %d\n",a,b,cmax);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment