`

Your Ride Is Here

阅读更多
   今天是我第一次在USACO上做题,虽然这是一个很简单很简单的题目,但是这个传说中USA培养参加IOI参赛选手的OJ,不仅让我有点向往啊。 这个OJ挺让人喜欢的。我很少自己认认真真的想题,也不少的OJ上都只是过过场,最近看了不少退役大牛的博文,顿时让我感到自己是多么的可笑,让我这只井里之蛙深刻的明白自己是多么的肤浅,感受到与其它人的巨大差异,这种差异不是在目前的能力上,而是在思想意识、觉悟上。

    今后我给自己定了如下的原则:

    1.做题一定要形成思路,不要一拿到题就一副大牛样子(还差得远呢)动键盘,
       敲代码,做题关键在于自己的思路,有了思路之后,也不要因为实现较为复杂
       不愿编码,另外做题也不要因为此题以前做过就不愿去做。记得上次的华中南赛,
       就因为这个毛病本来一个很简单的题目,就因为实现起来的代码比平时见到的水题就
       长就一直等到最后才去做。这些都说明自己仅仅是一个菜鸟而已。
   
    2.每做一道题目都要有自己的的收获。不要因为这一道题目涉及的算法很难懂就拖延到
      以后,到最后还是不懂。多花一点时间来把一个算法搞懂比自己去刷那几个水题来得
      强,来得实在。一定要把一个算法弄懂,否则就永远只是会那几个只能称为模板的水
      题,而算法稍微一变,就不知所云了。只有这样做题才有意义。

    3.要有死磕、钻研的精神。说实话,搞了这么久的ACM,局然从来没有这么过,说来我还
      没有入门呢。就拿这个USACO开始吧,听说如果能够在USACO上真正做出40%的题就有
      在国际上获银奖的实力呢。

   4.数学,这个现在越发觉得其真是太重要啦,真后悔啊,让数学贯穿整个ACM学习生涯。

   
    好了,说了这么多,总是不得要领,以后再想到什么再补充吧。
  
    回归正题。

   题目大意:给定两个串A,B,定义一个函数f(S):S中各个字母(注意只要大写字母)所代表的数字的乘积,如f("ABCZ")=1*2*3*26,串的长度不会超过6。如果f(A)%47==f(B)%47,则输出"GO",否则输出"STAY"。
   题目分析:此题是一个很水的题目,不过相对一个入门的人来说还是一个比较好的入门题的。涉及的知识点有:1.文件操作,这个对ACM来说其实不需要的,但由于这个信息学OJ,与我们要求不同。2.字母ASCII码的特点:连续的,所以很容易与数字一一对应。3.其它只是字符串操作而已。
    注意如果此题的字符串的长度不规定为6,就还涉及到数论经常会用到的一点小小的技巧:
(a*b)%c=((a%c)*(b%c))%c
   代码:
   
    /*
ID:xxfz014
PROG:ride
LANG:C++
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
    string s1,s2;
    ifstream fin("ride.in");
    ofstream fout("ride.out");
    fin>>s1>>s2;
    int len1=s1.length(),len2=s2.length();
    int res1=1,res2=1;
    for(int i=0;i<len1;i++) res1=res1*(s1[i]-'A'+1)%47;
    for(int i=0;i<len2;i++) res2=res2*(s2[i]-'A'+1)%47;
    if(res1==res2)  fout<<"GO"<<endl;
    else            fout<<"STAY"<<endl;
    fin.close();
    fout.close();
    return 0;
}

   

附:
Programming Contest Problem Types 

Hal Burch conducted an analysis over spring break of 1999 and made an amazing discovery: there are only 16 types of programming contest problems! Furthermore, the top several comprise almost 80% of the problems seen at the IOI. Here they are:

Dynamic Programming
Greedy
Complete Search
Flood Fill
Shortest Path
Recursive Search Techniques
Minimum Spanning Tree
Knapsack
Computational Geometry
Network Flow
Eulerian Path
Two-Dimensional Convex Hull
BigNums
Heuristic Search
Approximate Search
Ad Hoc Problems
The most challenging problems are Combination Problems which involve a loop (combinations, subsets, etc.) around one of the above algorithms - or even a loop of one algorithm with another inside it. These seem extraordinarily tricky to get right, even though conceptually they are ``obvious''.

If you can master solving just 40% of these problem types, you can almost guarantee a silver medal at the IOI. Mastering 80% moves you into the gold range almost for sure. Of course, `mastery' is a tough nut to crack! We'll be supplying a plethora of problems so that you can hone your skills in the quest for international fame.

   
分享到:
评论

相关推荐

    1_your ride is here_usaco_TheAnswer_YourRideisHere_

    标题 "1_your ride is here_usaco_TheAnswer_YourRideisHere_" 指的是USACO(美国计算机奥林匹克)训练平台上的一个编程练习题目。USACO是一个专门为中学生提供在线编程训练和竞赛的平台,旨在提升参赛者的算法和...

    USACO官网93题fps格式 OJ题库

    1 [1.1] 你的飞碟在这儿 Your Ride Is Here 2 [1.1] 贪婪的送礼者Greedy Gift Givers 3 [1.1] 黑色星期五Friday the Thirteenth 4 [1.1] 坏掉的项链 Broken Necklace 5 [1.2] 命名那个数字 Name That Number 6 [1.2]...

    USACO题解(NOCOW整理版)1

    具体包括了几个不同难度级别的问题,如“Your Ride Is Here”,“Greedy Gift Givers”,“Friday the Thirteenth”和“Broken Necklace”。每个问题的解析都提供了算法思想和解决方案,有的通过简单的数学计算,有...

    USACO所有题目题解

    本文主要解析其中三个题目:“Your Ride Is Here (ride)”,“Greedy Gift Givers (gift1)”,以及“Friday the Thirteenth (friday)”。 1. **Your Ride Is Here (ride)**: 这是一个相对简单的问题,属于"ad hoc...

    USACO英汉对照题目

    1.1.1 "Your Ride Is Here" 和 "Greedy Gift Givers" 可能涉及到基本的数据结构和贪心算法。 1.1.3 "Friday the Thirteenth" 可能需要理解日期和时间处理,以及可能的数学计算。 1.1.4 "Broken Necklace" 可能涉及...

    第1章总结1

    1.1节中的题目主要是模拟问题,例如"Your Ride Is Here"和"Greedy Gift Givers",通过模拟操作实现算法。同时,"Friday the Thirteenth"题目引入了模运算,"Broken Necklace"则涉及到数组的使用。 接着,1.2节重点...

    USACO(Train)解题报告.doc

    ### Chapter 1 Section 1.1 - Your Ride Is Here (ride) 这是一个相对简单的题目,通常被归类为“ad hoc”问题,即不需要复杂的算法或特定技巧。解题者通常需要根据题目描述直接逻辑推理,找出合适的解决方案。 ##...

    开心学英语六年级上期末复习题四(按要求完成句子)精选.doc

    9. **否定祈使句**:将肯定祈使句转换成否定形式,如 "You can ride your bikes here." 变为 "You cannot ride your bikes here." 10. **对动作的提问**:对正在进行的动作提问,如 "I am eating ice cream." 提问...

    2015年春七年级英语下册 Lesson 24 How was Your Weekend导学案(无答案)(新版)冀教版

    本文主要涉及了初中英语学习的内容,特别是针对冀教版七年级下册Lesson 24《How Was Your Weekend》的导学案。这个课程聚焦于谈论过去发生的事情和未来计划,以及相关的词汇、语法和句型训练。 1. **新单词和短语**...

    Unit3Howdoyougettoschool词句精讲精练-11页.pdf

    如“He runs very fast.”和“The rivers run into the sea.”此外,它还可以表示“流鼻涕”,如“Your nose is running, have you got a cold?” - 名词形式的“run”可指“跑;奔;路程;短期旅行”。例如:“It ...

    Unit 6 Let’s Go单元分课时练习(冀教版七上)2.doc

    2. **介词的用法**:在问句“Is your school far from here?”中,"from" 表示“离...远”。在句子“He comes here by bike.”中,“by”表示乘坐某种交通工具。 3. **动词短语**:题目中出现的“on foot”表示...

    小学英语试题_1.docx

    例如:"The girl is my sister"的中文是"这个女孩是我的妹妹","Don’t smoke"的中文是"不要吸烟","Here is the money"的中文是"给你钱","I 学习 English in a school"的英文是"I study English at a school","My...

    新起点二年级英语下册期中试卷精选.doc

    2. What is your favourite season? (你最喜欢的季节是什么?) 3. Here are some peanuts for you. (这是给你的一些花生) 4. Let us plant them. (让我们一起种它们) 5. Do you want to go to the park? (你想去公园...

    新版外研版四年级英语上册M5-6测试题精选.doc

    Here are your sweets. 5. She is our star. 6. Look at the bird in the sky. 7. He is making noodles. 8. They are watching TV. 9. What are you doing? I’m cooking vegetables. 10. Do you want some sweets...

    2019年七年级英语下册Unit3Howdoyougettoschool测试卷新版人教新目标版202004151164

    —About 15 minutes’ ride.` 和 `—How far is your teacher’s home from here? —It’s about two hours’ drive.` - `How long`通常询问持续时间,如第4题:`It takes them about half an hour to get to ...

    UberTrak_webApp_Main:UberTrak Web 应用程序主界面

    --Note here, this string ('.reideHistory') is the reference to your page--&gt; Ride History &lt;/a&gt;&lt;/li&gt; 在 UberTrack.js 添加: .state('stat.rideHistory', { //append your name string to 'stat' url: '...

Global site tag (gtag.js) - Google Analytics