Your Ride Is Here
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
string group, comet;
int x, y;
while (cin >> comet >> group)
{
x = y = 1;
for (int i = 0; i < comet.size(); i++)
{
x *= (comet[i] - 'A' + 1);
}
for (int i = 0; i < group.size(); i++)
{
y *= (group[i] - 'A' + 1);
}
if(x % 47 == y % 47)
{
cout << "GO" << endl;
}
else
{
cout << "STAY" << endl;
}
}
return 0;
}
Greedy Gift Givers
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
#pragma warning(disable : 4996)
int main()
{
freopen("in.txt", "r", stdin);
map<string, int>Map;
vector<string>name;
string str, temp;
int n, m, money, x, i;
bool flag = false;
while (cin >> n)
{
Map.clear();
name.clear();
for (i = 0; i < n; i++)
{
cin >> str;
name.push_back(str);
Map[str] = 0;
}
for (i = 0; i < n; i++)
{
cin >> temp >> money >> m;
if(m == 0)
{
continue;
}
Map[temp] -= money;
x = money / m;
money = money - x * m;
Map[temp] += money;
while (m--)
{
cin >> str;
Map[str] += x;
}
}
if(flag)
{
cout << endl;
}
flag = true;
for (i = 0; i < name.size(); i++)
{
cout << name[i] << " " << Map[name[i]] << endl;
}
}
return 0;
}