题目描述

It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a program which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.

Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where "A" is 1 and "Z" is 26. For instance, the group "USACO" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the same as the comet's number mod 47, then you need to tell the group to get ready! (Remember that "a mod b" is the remainder left over after dividing a by b; 34 mod 10 is 4.)

Write a program which reads in the name of the comet and the name of the group and figures out whether according to the above scheme the names are a match, printing "GO" if they match and "STAY" if not. The names of the groups and the comets will be a string of capital letters with no spaces or punctuation, up to 6 characters long.

输入

Line 1: An upper case character string of length 1..6 that is the name of the comet.
Line 2: An upper case character string of length 1..6 that is the name of the group.

输出

A single line containing either the word "GO" or the word "STAY".

样例输入

COMETQ
HVNGAT

样例输出

GO

分析:按题意走呗,他说怎样就怎样~。

#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define range(i,a,b) for(int i=a;i<=b;++i)
#define LL long long
#define rerange(i,a,b) for(int i=a;i>=b;--i)
#define fill(arr,tmp) memset(arr,tmp,sizeof(arr))
using namespace std;
string a,b;
LL mul1,mul2;
void init(){
cin>>a>>b;
mul1=mul2=;
}
void solve(){
range(i,,a.size()-)mul1*=a[i]-'A'+;
range(i,,b.size()-)mul2*=b[i]-'A'+;
cout<<(mul1%==mul2%?"GO":"STAY")<<endl;
}
int main() {
init();
solve();
return ;
}

【字符串】Your Ride Is Here的更多相关文章

  1. 洛谷 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He…【字符串+模拟】

    P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He… 题目描述 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都 ...

  2. USACO Section 1.1 Your Ride Is Here 解题报告

    题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...

  3. Section 1.1 Your Ride Is Here

    Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. TheseUFOs often com ...

  4. C++读取字符串数据的两种方式

    C++读取字符串数据的两种方式 对于同样的样例输入: ladder came tape soon leader acme RIDE lone Dreis peat ScAlE orb eye Ride ...

  5. USACO_1.1_Your_Ride_Is_Here_(字符串+水题)

    描述 http://train.usaco.org/usacoprob2?a=y0SKxY0Kc2q&S=ride 给出两个由大写字母组成,长度不大于$6$的字符串. 将字符串中的各字母的字典 ...

  6. USACO-Your Ride Is Here(你的飞碟在这儿)-Section1.2<1>

    [英文原题] Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs o ...

  7. usaco training <1.2 Your Ride Is Here>

    题面 Your Ride Is Here It is a well-known fact that behind every good comet is a UFO. These UFOs often ...

  8. Python 字符串格式化操作 - format方法

    建议使用format()方法 字符串操作 对于 %, 官方以及给出这种格式化操作已经过时,在 Python 的未来版本中可能会消失. 在新代码中使用新的字符串格式.因此推荐大家使用format()来替 ...

  9. Python高手之路【六】python基础之字符串格式化

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

随机推荐

  1. 使用java去对比2个带数学公式的字符串

    首先大家看到这个题目,可能会不屑一顾,呵呵,是的,起初我也认为这是个很简单的任务,当任务拿到手里后,经过我作为程序员来讲已经磨炼的无比通透的大脑来讲发现这其实是个坑. 故事的起因是这样的,想开发一款给 ...

  2. 安装LoadRunner11报缺少vc2005_sp1_with_atl_fix_redist的错误

    找到安装程序自带的lrunner\Chs\prerequisites\vc2005_sp1_redist,双击运行vcredist_x86.exe,再重新安装LoadRunner即可成功. 参考资料: ...

  3. 开源api文档

    蒲公英——API文档 https://www.pgyer.com/doc/api

  4. mac虚拟机上(centos系统)设置联网

    前面介绍了mac安装虚拟机VirtualBox,并在虚拟机上装上了centos,这里在说明一下联网问题. 首先打开centos系统,并输入命令$ ip addr 可得到如下: 发现找不到ip地址,这时 ...

  5. Linux认知之旅【02 装个软件玩玩】!

    〇.命令行终端熟悉了吗? 1.没有仔细研究上一篇文章? 拿上看看这几个命令:ls.cd.cp.mv.rm.mkdir.touch.cat.less.恩,暂时这些够用了! 什么?你连虚拟机也没装! 感谢 ...

  6. Abstract Factory 抽象工厂(创建型模式)

    1.常规的对象创建方法(以更换QQ空间主题为例) (这里的常规对象指的是由于业务需求,当前实例化的对象有可能被其他相似的对象(有着共同的特性)所取代,例如更换手机铃声:一首歌取代另一首歌(词,曲,和声 ...

  7. mysql语法结构

    环境:win7 64位.mysql 适合阅读者:对sql基本语法有一定了解 <建表语句>: create table <表名>( <列名> <类型> & ...

  8. rtmp jwplayer简单应用

    在nginx下使用,放到nginx/html文件夹内,之后访问 首先是播放vod视频 <!DOCTYPE html> <html xmlns="http://www.w3. ...

  9. maven学习(十六)——使用Maven构建多模块项目

    在平时的Javaweb项目开发中为了便于后期的维护,我们一般会进行分层开发,最常见的就是分为domain(域模型层).dao(数据库访问层).service(业务逻辑层).web(表现层),这样分层之 ...

  10. Spring 学习笔记(五)—— Bean之间的关系、作用域、自动装配

    继承 Spring提供了配置信息的继承机制,可以通过为<bean>元素指定parent值重用已有的<bean>元素的配置信息. <?xml version="1 ...