hdu 1032 水题也wrong 两次(于是乎更有刷水题的必要了)
2013-04-04 13:08
288 查看
题意:
清楚明了。
注意:
1.For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j
并没有说i<j一定成立;
2.The integers i and j must appear in the output in the same order in which they appeared in the input and should be followed by the maximum cycle length (on the same line).
i 和 j一定要输入的顺序与输出的顺序一样。
于是就可以RE了!!!
View Code
清楚明了。
注意:
1.For any two numbers i and j you are to determine the maximum cycle length over all numbers between i and j
并没有说i<j一定成立;
2.The integers i and j must appear in the output in the same order in which they appeared in the input and should be followed by the maximum cycle length (on the same line).
i 和 j一定要输入的顺序与输出的顺序一样。
于是就可以RE了!!!
View Code
#include<stdio.h> int main() { int n,m; int sum; int max; int i; int t,k; while(scanf("%d %d",&n,&m)!=EOF) { max=1; k=0; if(n>m){k=1;t=m;m=n;n=t;} for(int j=n;j<=m;j++) { i=j; sum=1; while(i!=1) { sum++; if(i%2==0)i/=2; else i=i*3+1; } if(sum>max)max=sum; } if(k==0)printf("%d %d %d\n",n,m,max); else printf("%d %d %d\n",m,n,max); } return 0; }
相关文章推荐
- HDU-1032 The 3n+1 problem 模拟问题(水题)
- HDU1032-The 3n + 1 problem-水题压惊
- HDU 1032 The 3n + 1 problem(水题)
- HDU 1032(水题)
- hdu水题十道,提高鸟语能力~~ 1032 1029 1033 1036 1037 1038 1039 1047 1856 1060 1061
- HDU 1032 The 3n + 1 problem 【水题】
- HDU 1032 水题
- hdu 2682 Tree 最小生成树~~~~水题一枚,,用到了筛法求素数,我竟然在格式上面PE了两次!!
- HDU 1032 The 3n + 1 problem (水题)
- hdu 1032 The 3n + 1 problem(水题)
- HDU-1032-The 3n + 1 problem(C++&学英语&水题)
- HDU 6075 Questionnaire 17多校4 水题
- hdu 3038 How Many Answers Are Wrong 带权并查集
- HDU 1032 3N+1
- HDU 5122 水题
- HDU2099 整除的尾数【水题】
- HDU 4287 Intelligent IME (map水题或字典树+DFS)
- hdu 5867 Water problem(2016 Multi-University Training Contest 10——水题)
- HDU1282+水题+模拟
- HDU 6168 - Numbers 水题 2017 Multi-University Training Contest - Team 9