Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:哪位帮忙看一下,WA~WA~,我实在是没辙了……In Reply To:哪位帮忙看一下,WA~WA~,我实在是没辙了…… Posted by:tangyuanamen at 2007-10-02 21:53:13 > #include <iostream> > using namespace std; > > int solve(int num1, int num2) > { > int max = 0; > for( int i = num1; i <= num2; i++) > { > int j = i; > int print_num = 1; > while( j != 1) > { > if(j%2 != 0) > j = (3*j+1); > else > j /= 2; > print_num++; > } > if(print_num > max) > max = print_num; > } > return max; > } > > int main(int argc, char*argv[]) > { > int m,n; > while(cin >> m >> n && m && n) > { > int p = m,q = n; > if( p > q) > { > int temp; > temp = p; > p = q; > q = temp; > } > int max = solve(p,q); > cout << m << " " << n << " " << max << endl; > } > return 0; > } 我也wa 了n次了,,不知道哪错了 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator