Your Ride Is Here your UFO here USACO simulation

1001: 1.1.1 Your Ride Is Here your UFO here

Time limit: 1 Sec   Memory Limit: 128 MB
submitted: 9   resolve: 9
[ submit ] [ state ] [ Discussion Board ] [proposition man: External Import]

Title Description

   1.1.1 Your Ride Is Here your UFO here

(Ride.pas / c / pp)

   As we all know, after each comet has a UFO. These UFO often come to collect loyal supporters on earth. Unfortunately, their flying saucer each trip can only bring a group of supporters. Therefore, they use a clever scheme to let these groups know ahead of time who was taken away by a comet. They played a name for each comet to determine that particular group this group is not being taken away by these names (Who do you think these comets to take the name of it?). Details on how the match will tell you the following; Your task is to write a program to determine whether this group could be behind the comet UFO taken by the group name and the name of the comet.

  Circle name and the name of the comet are converted into a digital in the following manner: the final number is in the name of all the letters of the plot, where "A" is 1, "Z" is 26. For example, "USACO" group is 21 * 19 * 15 * 1 * 3 = 17955. If the number is equal to the group's mod 47 digital comet mod 47, you have to tell the team needed to get ready! (Remember that "a mod b" is the remainder of a divided by b; 34 mod 10 is equal to 4)

  Write a program that reads comet names and group names and is calculated using the above two program names will be with them, if they can match, it outputs "GO", otherwise output "STAY". Circle name and the name of the comet are no spaces or punctuation string of capital letters (no more than six letters).

Input format (ride.in)

Line 1: a length of string to upper case 1 to 6, represents the name of the comet.

Line 2: the length of a string to upper case 1 to 6, represents the name of the team.

Output format (ride.out)

Only one row, including the "GO" or "STAY".

Sample input 1

COMETQ
HVNGAT

 Sample Output 1

GO

 Sample input 2

ABSTAR
USACO

 Sample Output 2

STAY

 

prompt

 

Source / classification

 

 

Oh a good simple question duck

Is to simulate on the list is 26 ^ 6 308 915 776

? ? Well longlong can certainly open a card too

 

#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    long long suma=1,sumb=1;
    for(int i=0;i<a.length();i++)
        suma*=(a[i]-'A'+1);
    for(int i=0;i<b.length();i++)
        sumb*=(b[i]-'A'+1);
    suma%=47;sumb%=47;
    if(suma==sumb)
        cout<<"GO";
    else
        cout<<"STAY";
        
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/Tidoblogs/p/11269328.html