⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pku1207.java

📁 这是ACM 方面的资料 是PKU的 北京大学的出来的
💻 JAVA
字号:
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner cin=new Scanner(System.in);
		int a,b,tmp,max,i,a2,b2;
		while(cin.hasNext())
		{
			a=cin.nextInt();
			b=cin.nextInt();
			a2=a;
			b2=b;
			if(a>b)
			{
				tmp=a;
				a=b;
				b=tmp;
			}
			for(i=a,max=0;i<=b;i++)
			{
				tmp=fun(i);
				if(tmp>max)
				{
					max=tmp;
				}
			}
			System.out.println(a2+" "+b2+" "+max);
		}
	}
	
	static int fun(int n)
	{
		int i=1;
		while(n!=1)
		{
			if(n%2==1) n=3*n+1;
			else n=n/2;
			i++;
		}
		return i;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -