zoukankan      html  css  js  c++  java
  • usaco1.1

    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;
    }




    Keep it simple!
    作者:N3verL4nd
    知识共享,欢迎转载。
  • 相关阅读:
    6.让代码更具可读性
    5构造函数和析构函数
    4面向对象之类的继承
    3隐形的指针
    2面向对象之类的封装
    od快捷键
    1.纠结的c++
    101宏定义的其他用法
    100解剖宏定义函数
    99,printf scanf手动功能实现
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5834960.html
Copyright © 2011-2022 走看看