Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <stdint.h>
- using namespace std;
- uint32_t coll(uint32_t n) {
- uint32_t k = 1;
- while (n != 1) {
- n = (n % 2) ? 3 * n + 1 : n / 2;
- k += 1;
- }
- return k;
- }
- int main(void) {
- uint32_t i, j;
- while (cin >> i) {
- cin >> j;
- if (i > j) {
- uint32_t tmp = i;
- i = j;
- j = tmp;
- }
- uint32_t now = i, m = 0;
- while (now <= j) {
- uint32_t tmp = coll(now);
- if (tmp > m) {
- m = tmp;
- }
- ++now;
- }
- printf("%u %u %u\n", i, j, m);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment