Skip to content

Instantly share code, notes, and snippets.

@hanjae-jea
Created August 20, 2018 08:44
Show Gist options
  • Save hanjae-jea/6a863365ccb5e755ae9c2470ad1934b3 to your computer and use it in GitHub Desktop.
Save hanjae-jea/6a863365ccb5e755ae9c2470ad1934b3 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int max, mlen, cnt, b, check[10000000];
int ubak(long long int a) {
if (a<10000000 && check[a] != 0)
return cnt + check[a];
cnt++;
if (a == 1)
return cnt;
if (a % 2 == 1) {
cnt++;
ubak((3 * a + 1) / 2);
}
else
ubak(a / 2);
return cnt; // 쌤이 문제를 잘 이해 못하겠지만 코드 의도상 이게 필요해보여서 이거만 추가헀다.
}
int main(void) {
int a;
scanf("%d %d", &a, &b);
for (int i = 1; i <= b; i++) {
cnt = 0;
check[i] = ubak((long long int)i);
}
for (int i = a; i <= b; i++) {
if (mlen<check[i]) {
mlen = check[i];
max = i;
}
}
printf("%d %d", max, mlen);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment