代码:
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define N 1005 int a[N]; int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) { int i,j; memset(a,0,sizeof(a)); int t1,t2; int x,y; for(i=0;i<n;i++) { scanf("%d%d",&x,&y); t1=t2=0; while(t1<m) { t1+=x; t2+=y; } a[i]=t2; } sort(a,a+n); printf("%d\n",a[0]); } return 0; }