Saleh127

UVA 694.cpp

Jun 15th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define Faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. Faster
  9. ll a,c,d,e,f,i,j,k,cnt,t=1;
  10. while(scanf("%lld %lld",&a,&c)==2)
  11. {
  12. if(a<0 && c<0) break;
  13. d=a;
  14. cnt=0;
  15. while(a<=c)
  16. {
  17. cnt++;
  18. if(a==1) break;
  19.  
  20. else if(a%2==0)
  21. {
  22. a=a/2;
  23. }
  24. else
  25. {
  26. a=3*a+1;
  27. }
  28. }
  29. printf("Case %lld: A = %lld, limit = %lld, number of terms = %lld\n",t++,d,c,cnt);
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment