为了熟悉一下code jam的平台,今天简单试了一下,做了一下Qualification Round Africa 2010的三道题目,都是很基础的。

  A题:给一个数n和一系列数a[],从a[]中找出两个数的和等于n,输出这两个数的下标。

 #include <cstdio>
#define MAXN 2010 int p[MAXN]; int main()
{
#ifdef LOCAL
freopen("A-large-practice.in", "r", stdin);
freopen("A.out", "w", stdout);
#endif
int T;
scanf("%d", &T);
for (int kase = ; kase <= T; kase++)
{
int c, n;
scanf("%d%d", &c, &n);
for (int i = ; i <= n; i++)
scanf("%d", &p[i]);
int i, j;
for (i = ; i <= n; i++)
for (j = i+; j <= n; j++)
if (p[i] + p[j] == c) goto s;
s: printf("Case #%d: %d %d\n", kase, i, j);
}
return ;
}

  B题:给出一行字母和空格组成的字符串,每个单词以空格隔开,将单词逆序输出。

 #include <cstdio>
#include <iostream>
#include <cctype>
#include <vector>
using namespace std; int main()
{
#ifdef LOCAL
freopen("B-large-practice.in", "r", stdin);
freopen("B.out", "w", stdout);
#endif
int T;
scanf("%d", &T);
getchar();
string str;
vector<string> v;
for (int kase = ; kase <= T; kase++)
{
v.clear();
getline(cin, str);
for (int i = ; i < str.size(); i++)
{
string t = "";
while (i < str.size() && isalpha(str[i]))
{
t += str[i];
i++;
}
v.push_back(t);
}
printf("Case #%d:", kase);
for (int i = v.size()-; i >= ; i--)
cout << " " << v[i];
printf("\n");
}
return ;
}

  C题:关于T9键盘的,给出一个字符输入序列(只含小写字母和空格),输出对应的按键序列。

 #include <cstdio>
#include <cstring>
#include <cctype> int main()
{
#ifdef LOCAL
freopen("C-large-practice.in", "r", stdin);
freopen("C.out", "w", stdout);
#endif
int table[][];
for (int i = ; i < ; i++)
{
table[i][] = i / + ;
table[i][] = i % + ;
}
for (int i = ; i < ; i++)
{
table[i][] = ;
table[i][] = i - ;
}
for (int i = ; i < ; i++)
{
table[i][] = ;
table[i][] = i - ;
}
for (int i = ; i < ; i++)
{
table[i][] = ;
table[i][] = i - ;
}
int T;
scanf("%d", &T);
getchar();
char str[];
for (int kase = ; kase <= T; kase++)
{
gets(str);
int pre = -;
int len = strlen(str);
printf("Case #%d: ", kase);
for (int i = ; i < len; i++)
{
if (str[i] == ' ')
{
if (pre == ) printf(" ");
printf("");
pre = ;
}
else if (isalpha(str[i]))
{
int t = str[i] - 'a';
if (table[t][] == pre) printf(" ");
for (int j = ; j < table[t][]; j++)
printf("%d", table[t][]);
pre = table[t][];
}
}
printf("\n");
}
return ;
}

  感觉数据都是比较规范的,比如B题明确说“每行开头和结尾没有空格,每个单词仅由一个空格分割”,没有太多的陷阱,也可能因为这是让熟悉平台的缘故吧,没想难为人...

  因为这是练习,所以只需要提交输出结果就行了,可以自己选择输入规模(Small input & Large input),不同的规模分值不同。记得看引导时说在比赛时要提交结果和源码,而且从开始下载输入文件到提交是有时间限制的(针对Small input和Large input分别为4min和8min),没参加过比赛,不清楚,-_-||...

  具体的还要以后更多了解啦...

初识Google code jam平台的更多相关文章

  1. [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha

    Problem B. Cookie Clicker Alpha   Introduction Cookie Clicker is a Javascript game by Orteil, where ...

  2. [Google Code Jam (Qualification Round 2014) ] A. Magic Trick

    Problem A. Magic Trick Small input6 points You have solved this input set.   Note: To advance to the ...

  3. [C++]Store Credit——Google Code Jam Qualification Round Africa 2010

    Google Code Jam Qualification Round Africa 2010 的第一题,很简单. Problem You receive a credit C at a local ...

  4. [C++]Saving the Universe——Google Code Jam Qualification Round 2008

    Google Code Jam 2008 资格赛的第一题:Saving the Universe. 问题描述如下: Problem The urban legend goes that if you ...

  5. Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words

    Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words https://code.google.com/cod ...

  6. Google Code Jam Africa 2010 Qualification Round Problem A. Store Credit

    Google Code Jam Qualification Round Africa 2010 Problem A. Store Credit https://code.google.com/code ...

  7. Google Code Jam 2010 Round 1C Problem A. Rope Intranet

    Google Code Jam 2010 Round 1C Problem A. Rope Intranet https://code.google.com/codejam/contest/61910 ...

  8. Google Code Jam 2014 资格赛:Problem B. Cookie Clicker Alpha

    Introduction Cookie Clicker is a Javascript game by Orteil, where players click on a picture of a gi ...

  9. Google Code Jam 资格赛: Problem A. Magic Trick

    Note: To advance to the next rounds, you will need to score 25 points. Solving just this problem wil ...

随机推荐

  1. Android Studio的使用(十二)怎样打包项目

    1.在导航栏的Build下面找到Generate Signed APK...,进入该菜单栏即可. 2.生成Key Store安全钥匙和证书的管理工具. 3.如果已经有了Key Store证书,则可以直 ...

  2. 用DIV+CSS做网页里要设置body和*规定内容

    body{}表示是对body标签的设置,就是<html><head></head><body></body></html> 里面 ...

  3. IPoint Interface接口

    Description A Point is a zero-dimensional object that represents a specific (X, Y) location in a the ...

  4. zf-关于公司框架的时间字段的格式转换问题。。

    <ww:date value="" format="yyyy-MM-dd">

  5. uboot1.1.6之NOR FLASH 出现的问题解决方法

    U-BOOT移植,structure has no member named `CAMDIVN speed.c: In function `get_HCLK':speed.c:114: error: ...

  6. StartUML 各种类图的例子

    1.UML分为: 1)静态建模:系统基础和系统固定框架结构,这些图形往往是“静态”的. 类图(Class Diagram):常用来分析业务概念 用例图(Use Case Diagram):常用 对象图 ...

  7. 跨域访问解决方案:JSONP

    关于什么是跨域请求,可以参见我之前的博文:http://www.cnblogs.com/LiuChunfu/p/5240145.html 上述博文最后有提到解决方案,一直说补充,但是工作忙忘了,直到朋 ...

  8. ecma6的学习好网站

    http://www.nodeclass.com/api/ECMAScript6.html#function http://es6.ruanyifeng.com/#docs/destructuring ...

  9. HDU 5172 GTY's gay friends 线段树

    GTY's gay friends Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  10. [算法] kmp实现

    字符串查找是经典场景,也是面试中最常见的一道题. 说来惭愧,毕业3年了,才明白了kmp算法的实现,以前一直以为这类算法是基础,工作中中不会碰到[也的确没有碰到过...] 但是,对这些基本算法结构的理解 ...