题目描述

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. Python 3基础教程16-类

    本文介绍类和简单使用,类是需要class这个关键字来声明的,一般如下面的语法: class className: def fun1(): pass def fun2(): pass 看下面demo.p ...

  2. 板载raid 安装Ubuntu 黑屏

    最近有碰到过产线反馈supermicro x10主板板载raid安装ubuntu桌面版 ,出现安装完成后黑屏,现象是能正常识别faker raid 但是第一次重启,就会出现黑屏,只有左上角广光标在闪, ...

  3. NGUI-使用UILabel呈现图片和不同格式的文字

    1.可以使用BBCode标记 [b]Bold[/b]                      粗体[i]italic[/i]                         斜体[u]underli ...

  4. python小结

    c:\python33添加到你的PATH 环境变量中,你可以在DOS 窗口中 输入以下命令:set path=%path%;C:\python33 id() 方法的返回值就是对象的内存地址. 在#! ...

  5. ASP.NET Core 2.1 源码学习之 Options[3]:IOptionsMonitor 【转】

    原文链接:https://www.cnblogs.com/RainingNight/p/strongly-typed-options-ioptions-monitor-in-asp-net-core. ...

  6. hnust 最小的x

    问题 G: 最小的x 时间限制: 1 Sec  内存限制: 128 MB提交: 2347  解决: 1155[提交][状态][讨论版] 题目描述 TSQ对DK进行地狱式训练,找出满足下面公式的最小的x ...

  7. COMMIT和ROLLBACK的用法

    从功能上划分,SQL语言可以分为DDL,DML和DCL三大类. 1.DDL(Data Definition Language)  数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 : C ...

  8. css控制文字模糊

    *{ color: transparent; text-shadow: #111 0 0 5px; }

  9. Custom LDAP Monitor Does Not Work

    Custom LDAP Monitor Does Not Work https://www.poppelgaard.com/netscaler-case-study-custom-ldap-monit ...

  10. if else以及大于、小于、等于逻辑表达式

    大多数情况下,可以使用测试命令来对条件进行测试.比如可以比较字符串.判断文件是否存在及是否可读等,通常用"[]"来表示条件测试.注意这里的空格很重要.要确保方括号的空格. if . ...