初识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 ...
随机推荐
- php socket客户端及服务器端应用实例
经常有朋友会对php的socket应用充满疑惑,本文就以实例代码作一讲解,希望能对初学php的朋友起到一点帮助作用 具体代码如下: 1.服务器端代码: <?php class SocketSer ...
- python插入mysql新值
#Server Connection to MySQL: import MySQLdb conn = MySQLdb.connect(host= "localhost", user ...
- 【转】使IFRAME在iOS设备上支持滚动
原文链接: Scroll IFRAMEs on iOS原文日期: 2014年07月02日 翻译日期: 2014年07月10日翻译人员: 铁锚 很长时间以来, iOS设备上Safari中超出边界的元素将 ...
- C#入门经典(第五章-2)字符串的处理
- tcp 重组原理
原文: http://blog.chinaunix.net/uid-21768364-id-4823449.html 1 .引言TCP/IP 协议现在已经广泛的被应用.数据在网络上应用 TCP/IP ...
- postgres 错误duplicate key value violates unique constraint 解决方案
SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1) 主要是:serial key其实是由sequence实现的,当 ...
- Anroid ListView分组和悬浮Header实现
Anroid ListView分组和悬浮Header实现 分类: Android2014-01-27 12:26 6585人阅读 评论(13) 收藏 举报 listviewheadersection分 ...
- FZU 2030 括号问题(回溯)
两种做法,一种dp,一种dfs,因为这个数据比较小,所以dfs全排列的方式是可以接受的,但是当比较大的时候就不行了,所以dp的方式还是要掌握一下的,我这里是dfs的做法,网上有很多人写的dp,可以去看 ...
- hrbustoj 2033 A Funny Game(对称博弈)
对称博弈,注释在代码里 #include<iostream> #include<cstdio> using namespace std; ///这个地方其实是博弈原理里面的对称 ...
- POJ 3648 Wedding
2-SAT,直接选择新娘一侧的比较难做,所以处理的时候选择新郎一侧的,最后反着输出就可以. A和B通奸的话,就建边 A->B'以及B->A’,表示 A在新郎一侧的话,B一定不在:B在新郎一 ...