URI Solution 1441 Hailstone Sequences - Solution in C++ | Ad Hoc
URI Online Judge Solution 1441 Hailstone Sequences
URI Main Problem Link - 1441 Hailstone Sequences https://www.urionlinejudge.com.br/judge/en/problems/view/1441
Problem Name: URI Problem 1441 Hailstone Sequences
Problem Number : URI Problem 1441 Hailstone Sequences Solution
Online Judge : URI Online Judge Solution
Level: Ad Hoc
Solution Language : C plus plus
URI Solution 1441 Hailstone Sequences Code in CPP:
#include <iostream> using namespace std; int main(int argc, char const *argv[]) { long h, m; while(cin >> h && h) { m = h; while(h != 1) { if(h % 2 == 0){ h /= 2; }else{ h *= 3; h++; } if(h > m) m = h; } cout << m << endl; } return 0; }
No comments:
Write commentsTo know more about the problem, give us your valuable commment. We'll try to help you. Thanks