初识Google code jam平台
为了熟悉一下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平台的更多相关文章
- [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 ...
- [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 ...
- [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 ...
- [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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- linux的mount(挂载)NFS 共享,命令详解
Linux下挂载(mount)光盘镜像文件.移动硬盘.U盘.Windows和NFS网络共享 linux是一个优秀的开放源码的操作系统,可以运行在大到巨型小到掌上型各类计算机系统上,随着 linux系统 ...
- int *p[4]与int (*q)[4]的区别
以上定义涉及两个运算符:“*”(间接引用).“[]”(下标),“[]”的优先级别大于“*”的优先级别. 首先看int *p[4],“[]”的优先级别高,所以它首先是个大小为4的数组,即p[4]:剩下的 ...
- 关于Context []startup failed due to previous errors有效解决方式
http://blog.csdn.net/mcpang/article/details/5468386
- ADB shell出现error:device offline提示
解决办法: 1.adb kill-server 2.adb start-server 3.adb remount执行这3个命令然后重新键入adb shell应该就可以了
- mongodb从来没有说它写成功了。
它只是说,yes,sir. http://www.infoq.com/cn/news/2014/04/bitcoin-banking-mongodb 开头的表述是错误的,官方说法它有4种类型的writ ...
- VC6.0 调试.dll文件
对于自己制作的.DLL文件,一直没有比较好的调试方法,其实是知道的太少. 下面就说说VC6.0下面 怎么调试DLL文件: 首先得有一个调用DLL文件的可执行程序,然后调用这个可执行程序. 在工程上 右 ...
- constraint 摘自群主大大
CONSTRAINT 子句 限制和索引相似,虽然限制也能被用于建立和另一个表的关联. 用 ALTER TABLE 和 CREATE TABLE 语句中的 CONSTRAINT 子句来建立或删除条件.C ...
- struts2 里escape="false"的问题?
<s:property value="html" escape="false"/> 没有name 不知道你是怎么取的值 <s:hidden n ...
- css div11
text-indent:30em; 缩进 font-family:"sans serif"文字的字体 border-width:1px; border-style:solid; ...
- 归心似箭,IT达人分享抢票攻略
[51CTO专稿]随着春节一天天临近,“购票难”的问题也愈发凸显,猎豹.火狐.360等“春运抢票神器”占领了各大网站的重要版面,“技术抢票”成为炙手可热的话题,看看身为程序员的邓以克是如何抢到回家的票 ...