1、智慧星球的武器
#include<iostream>
#include<map>
#include<vector>
#include<list>
using namespace std;
int main()
{
cout << "请输入部署几层结界:"<<endl;
int k;
int z; //结界类型1,2,3
int p; //对应类型结界型号
int d = 1; //初始范围为1
cin >> k;
//multimap<int,int>res;
vector<pair<int, int>>V;
while (k)
{
cin >> z >> p;
//res.insert(pair<int,int>(z,p));
V.push_back(pair<int, int>(z, p));
k--;
}
//对每一层进行处理,求范围
for (auto x : V)
{
if (x.first == 1)
{
d = d + x.second;
}
else if (x.first == 2)
{
d = d * x.second;
}
else if (x.first == 3)
{
if (d % x.second == 0)
d = d / x.second;
else
d = d / x.second + 1;
}
}
cout << "杀伤范围的边长为:" << d <<endl;
system("pause");
return 0;
}
2、匹配先验框