初识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 ...
随机推荐
- 未能加载文件或程序集 Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0 解决 亲测
项目打开winform程序做的某些窗体时报错: ************* 异常文本 ************** System.Reflection.TargetInvocationExceptio ...
- opencv 相关一个很好的博客
http://blog.csdn.net/zouxy09/article/category/1218765 图像卷积与滤波的一些知识点 图像卷积与滤波的一些知识点zouxy09@qq.comhttp: ...
- jQuery获取Select选中的Text和Value,根据Value值动态添加属性等
语法解释:1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发2. var ch ...
- angularJs中ngModel的坑
angular中指令被用的最多的除了ng-repeat之外就非他莫属了吧,由于各种业务的需求,我们经常需要去写一些继承ngModel的指令,来满足各种奇葩需求,最多的莫过于表单的验证啦,另外你在封装一 ...
- ms08_067利用过程
进入msf. show exploits. use exploit/windows/smb/ms08_067_netapi. show playloads. set PLAYLOAD windows/ ...
- SDAU课程练习--problemE
problemE 题目描述 "今年暑假不AC?" "是的." "那你干什么呢?" "看世界杯呀,笨蛋!" "@ ...
- FZU Problem 2029 买票问题(树状数组)
当我看到题目是5秒的时候,压根没有想树状数组,一直奔着模拟队列去想了,最后也没搞定,赛后看到大神的题解才恍然大悟,原来如此,题目中有明显的暗示,求前n项和,骤然感叹,自己太low... 果然还是要多做 ...
- PAT1011
With the 2010 FIFA World Cup running, 随着2010世界杯的举行 football fans the world over were becoming increa ...
- Transport layer and Network layer
http://stackoverflow.com/questions/13333794/networking-difference-between-transport-layer-and-networ ...
- Total Highway Distance
Total Highway Distance 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho are playing a ...