-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e4b370
commit a3eb2a3
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
```cpp | ||
#include <iostream> | ||
#include <vector> | ||
#include <map> | ||
#include <algorithm> | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
// 升级需要的总经验 | ||
int total; | ||
// 升一级的经验值 | ||
int z; | ||
// 情况数 | ||
int count = 0; | ||
// 经验值集合 | ||
vector<int> jy; | ||
cin >> total; | ||
while (cin >> z) | ||
jy.push_back(z); | ||
// 从小到大排列经验值 | ||
sort(jy.begin(), jy.end()); | ||
int size = jy.size(); | ||
// first可能的经验值,second出现的次数 | ||
map<int, int> value = {{total, 1}}; | ||
for (int i = size; i > 0; --i) | ||
{ | ||
// 到小的经验值之前 | ||
if (i > 1) | ||
{ | ||
auto temp_value = value; | ||
for (auto &j : temp_value) | ||
for (int k = 1; k <= j.first / jy[i - 1]; ++k) | ||
{ | ||
int t = j.first - k * jy[i - 1]; | ||
if (temp_value.find(t) == temp_value.end()) | ||
value.insert(pair<int, int>(t, 1)); | ||
else | ||
++value[t]; | ||
} | ||
} | ||
// 最后一个经验值,直接整除 | ||
else | ||
{ | ||
for (auto &j : value) | ||
if (!(j.first - j.first / jy[i - 1])) | ||
count += j.second; | ||
} | ||
} | ||
std::cout << count << endl; | ||
return 0; | ||
} | ||
``` |