Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- long long ok;
- long long Balance(long long r){
- if(r==1) {
- return ok;
- }
- if(r%2){
- r=3*r+1;
- Balance(r);
- ++ok;
- }
- else {
- r=r/2;
- Balance(r);
- ++ok;
- }
- }
- int main() {
- long long a,b;
- while(scanf("%lld%lld",&a,&b)==2){
- long long mx=0LL;
- int p=a;
- int q=b;
- if(a>b) swap(a,b);
- for(int i=a;i<=b;i++){
- ok=1;
- mx=max(mx,Balance(i));
- }
- printf("%lld %lld %lld\n",p,q,mx);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement