USACO Your Ride Is Here

1. 从今天开始做USACO了,系统的学习下;

2. 有详细的解题报告,可以看人家的代码,使自己的代码更简洁,更规范。


/*
ID: dollar4
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

long getnum(string str)
{
    long num = 1;
    for (unsigned int i = 0; i < str.length(); i++)
    {
        num *= (str[i] - 64);
        cout << str[i] << ' ' << num << endl;
    }
    return num % 47;
}

int main()
{
    ofstream fout ("ride.out");
    ifstream fin ("ride.in");
    string str1, str2;
    long num1, num2;
    fin >> str1 >> str2;
    num1 = getnum(str1);
    num2 = getnum(str2);
    if (num1 == num2)
        fout << "GO" << endl;
    else fout << "STAY" << endl;
    return 0;
}


你可能感兴趣的:(USACO)