http://acm.timus.ru/problem.aspx?space=1&num=1180

简单博弈 把前16个写出来就会发现 3 的倍数是奇异状态

因为 3 的倍数不可能为 2^k  

要证明 3 的倍数为奇异状态 可以用数学归纳法。

代码:

 

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		BigInteger n, m;
		BigInteger k = new BigInteger("3");
		while (in.hasNext()) {
			n = in.nextBigInteger();
			m = n.mod(k);
			if (m.equals(BigInteger.ZERO)) {
				System.out.println("2");
			} else {
				System.out.println("1");
				System.out.println(m);
			}
		}
	}

}

 

 

 

posted on 2012-10-17 16:47  夜->  阅读(144)  评论(0编辑  收藏  举报