通过的第一题,留做纪念,呵呵,非常简单,Africa 2010, Qualification Round: Store Credit。
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(void) 5 { 6 int N,C,I; 7 int *p; 8 int i,j,k; 9 freopen("in.in", "r", stdin); 10 freopen("out", "w", stdout); 11 scanf("%d",&N); 12 for(i=1;i<=N;i++) 13 { 14 15 scanf("%d",&C); 16 scanf("%d",&I); 17 18 p=(int *)malloc(sizeof(int)*I); 19 for(j=0;j<I;j++) 20 { 21 scanf("%d",p+j); 22 23 for(k=0;k<j;k++) 24 if(p[k]+p[j]==C) 25 goto out; 26 } 27 28 out: printf("Case #%d: %d %d ",i,k+1,j+1); 29 30 while (getchar()!=' ') 31 ; 32 free(p); 33 34 } 35 }