初识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 ...
随机推荐
- CodeForces 678C Joty and Chocolate
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- 微信小程序页面-页面跳转失败WAService.js:3 navigateTo:fail url not in app.json
微信小程序新建页面的要素一是新建的文件名称和其子文件的名称最好一致,不然容易出问题,在小程序页面跳转中如果出现WAService.js:3 navigateTo:fail url not in app ...
- 一个web项目在myeclipse中add deployment时无法被识别出来的原因
当我们一个web项目,在myeclipse中,add deployment时,可能发现,根本无法被识别成web项目,可能的原因有: 1. 项目的properties ->Myeclipse ...
- CSS样式覆盖规则
有一下问题, 想让下面的border生效 ,#比. 优先级高, #navigator { height: 100%; width: 200; position: absolute; left: 0; ...
- hibernate事务并发问题(脏读,不可重复读,幻读)
脏读 dirty read: 读了别的事务没有提交的事务, 可能回滚, 数据可能不对. 不可重复读 non repeatable read: 同一个事务里前后读出来的数据不一样, 被另一个事务影响 ...
- RocketMQ源码 — 三、 Producer消息发送过程
Producer 消息发送 producer start producer启动过程如下图 public void start(final boolean startFactory) throws MQ ...
- uboot1.1.6之NOR FLASH 出现的问题解决方法
U-BOOT移植,structure has no member named `CAMDIVN speed.c: In function `get_HCLK':speed.c:114: error: ...
- 转:Loadrunner上传文件解决办法(大文件)
最近再做一个跟海量存储相关的项目测试,需要通过LR模拟用户大量上传和下载文件,请求是Rest或Soap,同时还要模拟多种大小尺寸不一的文件 通常情况下,都是使用简单的post协议即可: 方法一: we ...
- PHP :Call to undefined function mysql_connect()
今天配置apache ,php,mysql 的时候,一直报(Call to undefined function mysql_connect()),PHP一直连接不上数据库,从网上查,答案也都是千篇一 ...
- USACO刷题之路
重拾经典 本科生涯结束了,在大学做的ACM竞赛现在基本忘的差不多了.USACO作为一个经典的题库,本来是面向OI选手的,但是由于题目质量很高所以受到大家的好评,所以我这次就从它开始我的刷题之路吧. 由 ...