记录编号 |
134301 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2012]国王游戏 |
最终得分 |
100 |
用户昵称 |
Asm.Def |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.034 s |
提交时间 |
2014-10-29 20:42:24 |
内存使用 |
0.33 MiB |
显示代码纯文本
#include <cstdio>
#include <iostream>
#include <cctype>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
#if defined DEBUG
FILE *in = fopen("test", "r");
#define out stdout
#else
FILE *in = fopen("kinggame.in", "r");
FILE *out = fopen("kinggame.out", "w");
#endif
template<typename T>inline void getint(T &x){
char c = fgetc(in);
while(!isdigit(c))c = fgetc(in);
x = c - '0';
while(isdigit(c = fgetc(in)))x = x * 10 - '0' + c;
}
typedef long long LL;
/*==================================================*/
struct BigN{
#define maxlen (1005)
#define base (10000)
int len, A[maxlen];
BigN():len(1){A[0] = 0;}
BigN(const int x):len(1){A[0] = x;}
void operator *= (const int x){
int slid = 0, i;
for(i = 0;i < len;++i){
A[i] = A[i] * x + slid;
slid = A[i] / base;
A[i] %= base;
}
while(slid){
A[i] = slid;
slid = A[i] / base;
A[i++] %= base;
}
len = i;
}
void operator /= (const int x){
for(int i = len - 1;i;--i){
A[i-1] += A[i] % x * base;
A[i] /= x;
}
A[0] /= x;
while(len > 1 && !A[len - 1])--len;
}
bool operator <(const BigN &b){
if(len != b.len)return len < b.len;
int i = len - 1;
while((~i) && A[i] == b.A[i]) --i;
return A[i] < b.A[i];
}
void put(FILE *Fout){
int i = len - 1;
fprintf(Fout, "%d", A[i]);
while(i)
fprintf(Fout, "%04d", A[--i]);
}
};
const int maxn = 1003;
int n;
struct s{
int L, R, M;
inline bool operator < (const s &b)const{
return M < b.M;
}
}S[maxn];
int main(){
int i;
getint(n);
getint(S->L), getint(S->R);
BigN Pro = S->L, Max = 0, tmp;
for(i = 1;i <= n;++i){
getint(S[i].L), getint(S[i].R);
S[i].M = S[i].L * S[i].R;
}
sort(S + 1, S + n + 1);
for(i = 1;i <= n;++i){
tmp = Pro;tmp /= S[i].R;
if(Max < tmp)Max = tmp;
Pro *= S[i].L;
}
Max.put(out);
return 0;
}