Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <algorithm>
- using namespace std;
- int a,b;
- int l,h,best;
- int count(int x) {
- int c=1;
- while (x!=1) {
- if (x&1) x=3*x+1;
- else x/=2;
- c++;
- }
- return c;
- }
- int main() {
- while(scanf("%d %d", &a,&b)!=EOF) {
- l=a, h=b,best=-1;
- if (l>h) swap(l,h);
- for (int i=l; i<=h; i++)
- best=max(best,count(i));
- printf("%d %d %d\n", a,b,best);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement