Posted on 2009-03-13 21:12
Hero 阅读(211)
评论(0) 编辑 收藏 引用 所属分类:
代码如诗--ACM
1 //1148 Accepted 0 76 682 C++
2 #include <stdio.h>
3 #include <stdlib.h>
4
5 const int size = 120 ;
6 int data[size] ;
7
8 int innum ;
9 int inn ;
10
11 int cmp( const void *a, const void *b )
12 {
13 return *(int *)a - *(int *)b ;
14 }
15
16 int main()
17 {
18 while( scanf( "%d", &innum ) != EOF )
19 {
20 while( innum -- )
21 {
22 scanf( "%d", &inn ) ;
23 for( int i=1; i<=inn; i++ ) scanf( "%d", &data[i] ) ;
24
25 qsort( data+1, inn, sizeof(data[1]), cmp ) ;
26
27 int diff = data[2] - data[1] ;
28 bool OK = true ;
29 for( int i=2; i<=inn; i++ )
30 {
31 if( data[i]-data[i-1] != diff )
32 {
33 OK = false ; break ;
34 }
35 }
36
37 if( OK ) printf( "yes\n" ) ;
38 else printf( "no\n" ) ;
39 }
40 }
41 return 0 ;
42 }