pku1405.java

来自「这是ACM 方面的资料 是PKU的 北京大学的出来的」· Java 代码 · 共 39 行

JAVA
39
字号
import java.io.*;
import java.util.*;
import java.math.BigInteger;

class Main
{
	public static void main(String args[]) throws Exception
	{
		Scanner cin=new Scanner(System.in);
		int i, n;
		
		BigInteger up, down, j;

		while(cin.hasNext())
		{
			up = BigInteger.ONE;
			down = BigInteger.ONE;
			n = cin.nextInt();
			
			for (i = 0; i < n; i++)
			{
				if (down.mod(up).equals(BigInteger.ZERO))
				{
					j = down.add(BigInteger.ONE).divide(up);
				}
				else
				{
					j = down.divide(up);
				}
				up = up.multiply(j);
				up = up.add(down.negate());
				down = down.multiply(j);
				System.out.println(j);
			}
		}

	}
}

⌨️ 快捷键说明

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