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 |
为什么我的程序不能达到0MS?#include <iostream> using namespace std; int main() { int temp1, temp2; while ( cin >> temp1 >> temp2) { int big = 0; int first = temp1 <= temp2 ? temp1 : temp2; int second = temp1 > temp2 ? temp1 : temp2; for (int i=first; i<=second; ++i) { int temp = i; int cnt = 1; while ( temp != 1) { ++cnt; if ( temp%2 == 0 ) temp = temp >> 1; else temp = temp + (temp << 1) + 1; } if (cnt > big) big = cnt; } cout << temp1 << " " << temp2 << " " << big << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator