#include #include #include #include using namespace std; const int N=1e2+3,Inf=1e9+7; struct node{ int x,y; bool operator <(const node &o)const{ return (1.0*this->x/this->y)>(1.0*o.x/o.y); } }; node a[N]; /* 从第k瓶开始喝,喝够m需要的最小代价 */ int n,m; int dfs(int k,int m){ if(m==0) return 0; int ans=(m/a[k].x)*a[k].y;//ans代价 if(m%a[k].x==0) return ans; return (ans+a[k].y); } int main(){ int T; scanf("%d",&T); while(T--){ scanf("%d %d",&n,&m); for(int i=0;i