C++ · problem solving

USACO 1.1.1 Your Ride Is Here

/*
ID: ahmedye1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ifstream inputFile (“ride.in”);
ofstream outputFile (“ride.out”);
string groupName;
string cometName;
int groupNum = 1;
int cometNum = 1;

if (inputFile.is_open())
{
inputFile >> cometName >> groupName;

for (int i = 0; i < cometName.length(); i++)
cometNum *= int (cometName[i] – 64);

for (int i = 0; i < groupName.length(); i++)
groupNum *= int (groupName[i] – 64);

if (groupNum % 47 == cometNum % 47)
outputFile << “GO” << endl;
else
outputFile << “STAY” << endl;
}

return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s