More actions
imported>talin0528 No edit summary |
imported>talin0528 No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Status == | |||
{| class="wikitable" | |||
|- | |||
| Problem | |||
| 1207 | |||
| User | |||
| talin0528 | |||
|- | |||
| Memory | |||
| 252K | |||
| Time | |||
| 16MS | |||
|- | |||
| Language | |||
| C++ | |||
| Result | |||
| Accepted | |||
|} | |||
== Source Code == | |||
#include <iostream> | #include <iostream> | ||
using namespace std; | using namespace std; | ||
| Line 28: | Line 47: | ||
return 0; | return 0; | ||
} | } | ||
---- | |||
[[ACM_ICPC/2011년스터디]] | |||
Latest revision as of 07:27, 4 June 2011
Status
| Problem | 1207 | User | talin0528 |
| Memory | 252K | Time | 16MS |
| Language | C++ | Result | Accepted |
Source Code
#include <iostream>
using namespace std;
int length(int n){
int len = 1;
while(n != 1){
if(n%2 == 1)
n = 3*n+1;
else
n = n/2;
len++;
}
return len;
}
int maxLength(int num1, int num2){
int i, j, max=0;
j = num1<num2? num2 : num1;
for(i = num1<num2? num1 : num2; i <=j; i++){
if(max < length(i))
max = length(i);
}
return max;
}
int main(){
int num1, num2;
while(cin>>num1>>num2)
cout<<num1<<" "<<num2<<maxLength(num1, num2);
return 0;
}