通过的第一题,留做纪念,呵呵,非常简单,Africa 2010, Qualification Round: Store Credit。
#include <stdio.h>
#include <stdlib.h> int main(void)
{
int N,C,I;
int *p;
int i,j,k;
freopen("in.in", "r", stdin);
freopen("out", "w", stdout);
scanf("%d",&N);
for(i=;i<=N;i++)
{ scanf("%d",&C);
scanf("%d",&I); p=(int *)malloc(sizeof(int)*I);
for(j=;j<I;j++)
{
scanf("%d",p+j); for(k=;k<j;k++)
if(p[k]+p[j]==C)
goto out;
} out: printf("Case #%d: %d %d\n",i,k+,j+); while (getchar()!='\n')
;
free(p); }
}
Credit.c