HDACM1021
Print the word “yes” if 3 divide evenly into F(n).这一句为关键,就是f(n)能被3整除就输出yes。
可通过寻找循环节去做,应该是每8次一循环//1 2 0 2 2 1 0 1 1 2 0
import java.util.Scanner;public class Main{public static void main(String[] args) {//1 2 0 2 2 1 0 1 1 2 0int[] a = new int[8];a[0]=7;a[1]=11;for (int i = 2; i < a.length; i++) {a[i] = (a[i-2]+a[i-1])%3;}Scanner sc = new Scanner(System.in);while (sc.hasNext()) {int n = sc.nextInt();if (a[n%8]==0) {System.out.println("yes");continue;}System.out.println("no");}}
}