| 比赛 |
五一大礼包 |
评测结果 |
AAAEAEAAAE |
| 题目名称 |
国王游戏 |
最终得分 |
70 |
| 用户昵称 |
xuyuqing |
运行时间 |
0.560 s |
| 代码语言 |
C++ |
内存使用 |
3.73 MiB |
| 提交时间 |
2026-05-04 09:14:26 |
显示代码纯文本
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
const int N = 1145;
const int Base = 10;
int n;
pair<long long, long long> nums[N];
struct ShiProblem {
vector<int> nums;
ShiProblem (vector<int> nums) : nums (nums) {}
void operator *= (long long num) {
for (int i = 0; i < nums.size(); i++) {
nums[i] *= num;
}
for (int i = 0; i < nums.size() - 1; i++) {
if (nums[i] >= Base) {
nums[i + 1] += nums[i] / Base;
nums[i] %= Base;
}
}
while (*(nums.rbegin()) >= Base) {
nums.push_back(*(nums.rbegin()) / Base);
*(nums.rbegin() + 1) %= Base;
}
}
ShiProblem operator/ (long long num) {
ShiProblem ans = *this;
long long t = 0;
for (auto it = ans.nums.rbegin(); it != ans.nums.rend(); it++) {
t = t * 10 + *it;
*it = 0;
if (t >= num) {
*it = t / num;
t = t % num;
}
}
while (!(*(ans.nums.rbegin()))) {
ans.nums.pop_back();
}
return ans;
}
bool operator< (ShiProblem other) {
if (nums.size() != other.nums.size()) {
return (nums.size() < other.nums.size());
}
for (int i = nums.size() - 1; i >= 0; i--) {
if (nums[i] != other.nums[i]) {
return (nums[i] != other.nums[i]);
}
}
return false;
}
void display () {
for (auto it = nums.rbegin(); it != nums.rend(); it++) {
cout << *it;
}
cout << endl;
}
};
ShiProblem cal {vector<int> {1}};
ShiProblem res {vector<int> {0}};
bool cmp (pair<long long, long long> one, pair<long long, long long> two) {
return one.first * one.second < two.first * two.second;
}
int main () {
freopen ("kinggame.in", "r", stdin);
freopen ("kinggame.out", "w", stdout);
cin >> n;
for (int i = 0; i <= n; i++) {
cin >> nums[i].first >> nums[i].second;
}
sort (nums + 1, nums + 1 + n, cmp);
for (int i = 1; i <= n; i++) {
cal *= nums[i - 1].first;
auto t = cal / nums[i].second;
if (res < t) {
res = t;
}
}
res.display();
return 0;
}