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
    知识共享,欢迎转载。
  • 相关阅读:
    [剑指 Offer 11. 旋转数组的最小数字]
    进程描述符(PCB)
    [剑指 Offer 57. 和为s的两个数字]
    Linux netstat命令
    kafka2.3.X配置文件
    docker
    shell操作mysql数据库
    Linux文件查找之find命令
    sed 切割日志文件
    Linux文本处理之awk
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5834960.html
Copyright © 2011-2022 走看看