标签:
没看清题号,TimeLimit。啊。 直接计算次数即可。
代码 :
import java.util.*; public class Main1954 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); while(t-- > 0) { int[] a = new int[16]; int n = scan.nextInt(); for(int i=0; i<n; i++) { a[i] = scan.nextInt(); } int flag = 0; for(int k=0; k<200; k++) { int cnt = 0; int[] b = new int[16]; for(int i=0; i<n; i++) { if(i == n-1) b[i] = Math.abs(a[n-1]-a[0]); else b[i] = Math.abs(a[i] - a[i+1]); if(b[i] == 0) cnt ++; } if(cnt == n) { flag = 1; break; } a = b; //System.out.println(a[0] + " " + a[1] + " " + a[2] + " " + a[3]); } if(flag == 1) System.out.println("ZERO"); else System.out.println("LOOP"); } } }
标签:
原文地址:http://blog.csdn.net/wxisme/article/details/42176841