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 |
大佬们求助啊啊啊啊啊,小子不才,被水题撂倒#include <stdio.h> int main(int argc, char const *argv[]) { int a, b, num; int max = 0; int temp; int flag = 0; while (scanf("%d%d", &a, &b) != EOF) { if (a > b) { temp = a; a = b; b = temp; flag = 1; } max = 0; for (int i = a; i < b + 1; ++i) { num = 1; if (a == 1 && b == 1) { max = 2; } for (int j = i; j != 1; ) { if (j % 2 == 1) { j = 3 * j + 1; } else if (j % 2 == 0) { j = j / 2; } ++num; if (num > max) max = num; } } if (flag == 0) { printf("%d %d %d\n", a, b, max); } else { printf("%d %d %d\n", b, a, max); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator