#P1200. [USACO1.1] 你的飞碟在这儿 Your Ride Is Here
[USACO1.1] 你的飞碟在这儿 Your Ride Is Here
Description
As everyone knows, there is a UFO behind every comet. These UFOs often come to gather loyal supporters on Earth. Unfortunately, their saucer can take only one group of supporters on each trip. Therefore, they use a clever scheme to let the groups know in advance who will be taken by a comet. They give each comet a name and use these names to decide whether a particular group is the one to be taken (who do you think names these comets?). The details of how to match are given below; your task is to write a program that, given a group name and a comet name, decides whether the group will be taken by the UFO behind that comet.
Both the group name and the comet name are converted into a number as follows: the final number is the product of the values of all letters in the name, where is and is . For example, the group yields . If the group’s number equals the comet’s number , you should tell the group to get ready to go! (Remember that "" is the remainder when is divided by ; for example, equals .)
Write a program that reads the comet name and the group name and determines whether the two names match under the scheme above. If they match, output GO; otherwise, output STAY. Both the group name and the comet name are strings of uppercase letters with no spaces or punctuation (at most letters).
Input Format
Line 1: An uppercase string of length to , the comet's name.
Line 2: An uppercase string of length to , the group's name.
COMETQ
HVNGAT
GO
ABSTAR
USACO
STAY
Hint
Problem translation from NOCOW.
USACO Training Section 1.1.
Translated by ChatGPT 5
京公网安备 11011102002149号