zoukankan      html  css  js  c++  java
  • Google Code Jam 第一题

    通过的第一题,留做纪念,呵呵,非常简单,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 }
    Credit.c
  • 相关阅读:
    最短Hamilton路径-状压dp解法
    泡芙
    斗地主
    楼间跳跃
    联合权值
    虫食算
    抢掠计划
    间谍网络
    城堡the castle
    【模板】缩点
  • 原文地址:https://www.cnblogs.com/zackcoder/p/3247380.html
Copyright © 2011-2022 走看看