记录编号 |
69468 |
评测结果 |
AAAAA |
题目名称 |
耐磨的登山包 |
最终得分 |
100 |
用户昵称 |
Pom |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.132 s |
提交时间 |
2013-09-16 19:25:48 |
内存使用 |
3.41 MiB |
显示代码纯文本
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define I Integer
#define O operator
#define F friend
#define R return
#define T ostream&
int i;using namespace std;
class I{private:int M[401],l,S;public:
I(){}int Z(){if(l==1&&M[1]==0){S=1;R 1;}R 0;}
void C(){for(l=400;l>1&&M[l]==0;l--);}I(int n){if(n<0)S=-1;else S=1;n=abs(n);memset(M,0,sizeof(M));
l=(n==0);while(n){M[++l]=n%10;n/=10;}}I(string n){if(n[0]=='-')S=-1;else S=1;memset(M,0,sizeof(M));
l=n.size()-(n[0]=='-');for(i=1;i<=l;i++)M[l-i+1]=n[i-1+(n[0]=='-')]-48;Z();C();}
void II(string n){if(n[0]=='-')S=-1;else S=1;memset(M,0,sizeof(M));l=n.size()-(n[0]=='-');
for(i=1;i<=l;i++)M[l-i+1]=n[i-1+(n[0]=='-')]-48;Z();C();}int& O[](int n)
{R M[n];}F T O<<(T,I);F I O-(I);F int O==(I,I);F int O<(I,I);F I O+(I,I);F I O*(I,I);
F I O/(I,I);};T O<<(T U,I N){N.Z();N.C();if(!~N.S)U<<'-';for(i=N.l;i>=1;i--)U<<N[i];R U;
}I O-(I A){if(A.l==1&&A[1]==0)R A;I C(A);C.S=-C.S;R C;}int O==(I A,I B){if(A.l!=B.l||A.S!=B.S)R 0;
for(i=1;i<=A.l;i++)if(A[i]!=B[i])R 0;R 1;}int O!=(I A,I B){R 1-(A==B);}int O<(I A,I B){if((A.S>B.S)||
(A==B))R 0;if(A.S<B.S)R 1;if(A.S+B.S==2){if(A.l<B.l)R 1;if(A.l>B.l)R 0;for(i=A.l;i>=1;i--){if(A[i]<B[i])R 1;
if(A[i]>B[i])R 0;}R -1;}if(A.l>B.l)R 1;if(A.l<B.l)R 0;for(i=A.l;i>=1;i--){if(A[i]<B[i])R 0;if(A[i]>B[i])R 1;
}R -1;}int O<=(I A,I B){R A<B||A==B;}int O>(I A,I B){R 1-(A<=B);}int O>=(I A,I B){R 1-(A<B);}I O+(I A,I B)
{I C(0);if(!(A.S-B.S)){for(i=1;i<=max(A.l,B.l)+1;i++){C[i]=A[i]+B[i]+C[i-1]/10;C[i-1]%=10;}
if(A.S+B.S==-2)C.S=-1;C.C();R C;}if(B.S-A.S==2)swap(A,B);C=-B;if(A<C)C.S=-1;else swap(A,C);
for(i=1;i<=C.l;i++){C[i]-=A[i];if(C[i]<0){C[i]+=10;C[i+1]--;}}C.C();R C;}I O+(I A,int B){I C(B);C=C+A;R C;}
I O+(int A,I B){R B+A;}void O+=(I &A,I B){A=A+B;}I O++(I &A){A=A+1;R A;}I O++(I &A,int b){I C(A);A=A+1;R C;}
I O-(I A,I B){R -B+A;}void O-=(I &A,I B){A=A-B;}I O--(I &A){A=A-1;R A;}I O--(I &A,int b){I C(A);A=A-1;R C;}
I O*(I A,I B){I C(0);int j;for(i=1;i<=A.l;i++)for(j=1;j<=B.l;j++)C[i+j-1]+=A[i]*B[j];for(i=1;i<400;i++)
{C[i]+=C[i-1]/10;C[i-1]%=10;}C.S=A.S*B.S;C.C();R C;}void O*=(I &A,I B){A=A*B;}I O/(I A,I B){int i,j;I C(0);
if(B.Z()||(A<B))R C;C.l=A.l;for(i=A.l;i>=1;i--){for(j=1;j<=10;j++){C[i]=j;if(C*B>A)break;}C[i]=j-1;}C.C();
R C;}void O/=(I &A,I B){A=A/B;}I O%(I A,I B){R A-(A/B*B);}void O%=(I &A,I B){A=A%B;}
const int MAXN=1009;
int n;
I a[MAXN],b[MAXN];
string s1,s2;
int main()
{
freopen("mountainbag.in","r",stdin);
freopen("mountainbag.out","w",stdout);
scanf("%d",&n);
int k;
for (k=0;k<n;k++)
{
cin>>s2>>s1;
b[k].II(s2);
a[k].II(s1);
}
int ans=0;
for (k=1;k<n;k++)
if (a[0]*b[k]<a[k]*b[0])
{
a[0]=a[k];
b[0]=b[k];
ans=k;
}
printf("%d\n",ans);
return 0;
}