poj 1207

继续水题

#include <stdio.h>
int i,x,y,a,b,temp;
int cycel(int i);
int cycle(int i)
{
    int j = 1;
    while( i != 1)
    {
        if(i%2)
            i = 3*i+1;
        else
            i = i/2;
        j++;
    }
    return j;
}

int main(void)
{
    while(scanf("%d %d",&a,&b))
    {
        int max = 0;
        x = a<b?a:b;
        y = a>b?a:b;
        for (i = x; i <= y; i++)
        {
            temp = cycle(i);
            if(max < temp)
                max = temp;
        }
        printf("%d %d %d\n",a, b, max);
    }
    return 0;
}

  

时间: 2025-01-01 21:03:16

poj 1207的相关文章

计算次数,POJ(1207)

题目链接:http://poj.org/problem?id=1207 #include <stdio.h> #include <algorithm> using namespace std; int i,j; int Max; int fun(int k) { int Count=1; while(k!=1) { if(k%2==1) k=k*3+1; else k/=2; Count++; } return Count; } int main() { while(scanf(&

POJ 1207 3N+1 Problem

更简单的水题,穷举法即可. 需要注意的点: 1.i 和 j的大小关系不确定,即有可能 i>j 2.即使i>j,最后输出的结果也要严格按照输出,亦即如果 1 /* 2 * File: 1207.h 3 * Author: chrischeng021 <[email protected]> 4 * 5 * Created on July 9, 2015, 5:07 PM 6 */ 7 8 #ifndef _1207_H 9 #define _1207_H 10 11 int calcu

POJ 1207 The 3n + 1 problem (数学)

The 3n + 1 problem Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 53448   Accepted: 16999 Description Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In th

POJ题目推荐(转载)

POJ推荐50题1.标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉.2.标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目.3.列表中大约有70个题目.大家选做其中的50道,且每类题目有最低数量限制.4.这里不少题目在BUPT ACM FTP上面都有代码,请大家合理利用资源.5.50个题目要求每个题目都要写总结,养成良好的习惯.6.这个列表的目的在于让大家对各个方面的算法有个了解,也许要求有些苛刻,教条,请大家谅

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

ACM训练方案-POJ题目分类

ACM训练方案-POJ题目分类 博客分类: 算法 ACM online Judge 中国: 浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 杭州电子科技大学(HDU):http://acm.hdu.edu.cn/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 北京航天航空大学(BUAA)http://acm.buaa.edu.cn/oj/index.php 南京

转载:poj题目分类(侵删)

转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K–0.50K:中短代码:0.51K–1.00K:中等代码量:1.01K–2.00K:长代码:2.01K以上. 短:1147.1163.1922.2211.2215.2229.2232.2234.2242.2245.2262.2301.2309.2313.2334.2346.2348

POJ训练计划

POJ训练计划 Step1-500题 UVaOJ+算法竞赛入门经典+挑战编程+USACO 请见:http://acm.sdut.edu.cn/bbs/read.php?tid=5321 一.POJ训练计划 Moon修订 298道题集训第一天 POJ纯水题 = =: 17道题 2017 1218 2000 1046 1218 1003 1004 1005 1008 1013(枚举) 1207 1552 2105 2388 1316 2499 3006(筛法求素数) 正式集训计划: 未做  已做 

poj题库分类

初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推.     (5)构造法.(poj3295)     (6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)二.图算法:     (1)图的深度优先遍历和广度优先遍历.     (2)最短路径算法(dijkstra,bellman-ford,floyd,hea