/*
* 分析:
* 贪心+高精度。。。尽量凑3,不足凑2
*
* */

http://www.lydsy.com/JudgeOnline/problem.php?id=1263 

import java.util.Scanner;
import java.math.*;

public class Main{
	public static void main(String [] args){
		BigInteger ans;
		BigInteger th = BigInteger.valueOf(3);
		int n;
		
		Scanner cin = new Scanner(System.in);

		while(cin.hasNext()){
			n = cin.nextInt();
			if(n==1){
				System.out.println(1);
				System.out.println(1);
				continue;
			}
			ans = BigInteger.ONE;
			int three = 0;
			while(n>4){
				three ++;
				n -= 3;
			}
			if(n==4||n==2)
				ans = ans.multiply(BigInteger.valueOf(n));
			else if(n==3)
				three ++;
			for(int i=0;i<three;i++)
				ans = ans.multiply(th);
			String s = ans.toString();
			System.out.println(s.length());
			if(s.length()>100){
				for(int i=0;i<100;i++)
					System.out.print(s.charAt(i));
				System.out.println();
			}
			else
				System.out.println(ans);
		}
	}
}

  

 

相关文章:

  • 2021-07-25
  • 2022-02-26
  • 2022-12-23
  • 2021-05-21
  • 2021-06-06
  • 2022-01-19
猜你喜欢
  • 2021-05-24
  • 2022-12-23
  • 2021-11-04
  • 2022-01-19
  • 2021-09-16
  • 2021-08-21
相关资源
相似解决方案