【字符串】Your Ride Is Here
题目描述
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 2: An upper case character string of length 1..6 that is the name of the group.
输出
样例输入
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的更多相关文章
- 洛谷 P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He…【字符串+模拟】
P1200 [USACO1.1]你的飞碟在这儿Your Ride Is He… 题目描述 众所周知,在每一个彗星后都有一只UFO.这些UFO时常来收集地球上的忠诚支持者.不幸的是,他们的飞碟每次出行都 ...
- USACO Section 1.1 Your Ride Is Here 解题报告
题目 问题描述 将字符串转变为数字,字母A对应的值为1,依次对应,字母Z对应的值为26.现在有一个字符串,将其中的每个字符转变为数字之后进行累乘,最终的结果对47求余数. 题目给你两个字符串,其中的字 ...
- 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 ...
- C++读取字符串数据的两种方式
C++读取字符串数据的两种方式 对于同样的样例输入: ladder came tape soon leader acme RIDE lone Dreis peat ScAlE orb eye Ride ...
- USACO_1.1_Your_Ride_Is_Here_(字符串+水题)
描述 http://train.usaco.org/usacoprob2?a=y0SKxY0Kc2q&S=ride 给出两个由大写字母组成,长度不大于$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 ...
- 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 ...
- Python 字符串格式化操作 - format方法
建议使用format()方法 字符串操作 对于 %, 官方以及给出这种格式化操作已经过时,在 Python 的未来版本中可能会消失. 在新代码中使用新的字符串格式.因此推荐大家使用format()来替 ...
- Python高手之路【六】python基础之字符串格式化
Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...
随机推荐
- Jmeter 参数化之 CSV Data Set Config 循环读取参数
对于做接口和性能测试,个人感觉Jmeter是一个非常方便易学的工具,今天随笔记录Jmeter 参数化之 CSV Data Set Config. 首先在开始记录之前,先搞明白2个问题 1.什么是参数化 ...
- Python 3基础教程5-while循环语句
本文开始介绍循环语句,和其他编程语言一样,Python中有while循环和for循环,这里介绍while循环. 语法: while 条件表达式为真: 做一些事情 实际生活中有很多这样的循环场景,这里举 ...
- python负数除法与模运算
1.负数除法: >>> print 45/76>>> print -45/7-7 >>> print 45/-7-7 >>> p ...
- PoolManager
我用的PoolManager版本是5.5.2的,导入的包总共有三个文件夹:Editor,Plugins,PoolManagerExampleFiles 1.Editor这个文件夹里面的东西,顾名思义, ...
- React跨域问题解决
https://segmentfault.com/q/1010000012732581 非跨域问题报错 -rpccorsdomain="http://localhost:3000" ...
- shell sort 排序大讨论
转自http://roclinux.cn 本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. === [正文开始]有时候学 ...
- Tomcat 顶层结构
Tomcat中最顶层的容器叫Server,代表整个服务器,Server中包含至少一个Service,用于具体提供服务. Service主要包含两部分:Connector 和 Container ...
- 想了一天的题目QAQ 毛线数列的最值
#include <cstdio> #include <cstring> #include <cmath> #include <iostream> #i ...
- vue cli & vue 3.x
vue cli & vue 3.x https://cli.vuejs.org/dev-guide/ui-api.html#ui-api https://cli.vuejs.org/zh/gu ...
- 基于RRT的机器人自主探索建图
一.方法讲解: 本项目分为三个部分:机器人周围一定范围内基于RRT的全局检测, 根据上一步检测的未知区域点执行sklearn.cluster.MeanShift聚类,获取聚类中心: 根据聚类中心计算各 ...