// Shoemaker's Problem.cpp : Defines the entry point for the console application. // #include "stdafx.h" using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int testround=0; cin>>testround; cout<<"/n"; while(testround>0) { int testdata=0; cin>>testdata; int *day=new int[testdata]; double *dollar=new double[testdata]; double *index=new double[testdata]; double *comindex=new double[testdata]; for(int i=0;i<testdata;++i)cin>>day[i]>>dollar[i]; for(int x=0;x<testdata;++x)index[x]=(double)dollar[x]/day[x]; for(int y=0;y<testdata;++y)comindex[y]=index[y]; for(int m=testdata-1;m>0;--m) { for(int n=0;n<m;++n) { if(index[n]>index[n+1]) { double tmp=index[n]; index[n]=index[n+1]; index[n+1]=tmp; } } } int beforeindex=testdata; for(int p=testdata-1;p>=0;--p) { for(int q=0;q<testdata;++q) { if((fabs(index[p]-comindex[q])<0.00001)&&(q!=beforeindex)) { beforeindex=q; cout<<q+1<<" "; break; } } } --testround; cout<<"/n"; delete []day; delete []dollar; delete []index; } system("pause"); return 0; }