背包问题加强版orz
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
long long a[][],f[],n,m,a1[],b1[];
int main()
{
cin>>n>>m;
int i,j,k;
for (i=;i<=m;i++)
cin>>a1[i]>>b1[i];
for (i=;i<=m;i++)
for (j=;j<=n;j++)
a[i][j]=a1[i]*pow(j,b1[i]);
memset(f,,sizeof(f));
f[]=;
for (i=;i<=m;i++)
for (j=n;j>=;j--)
for (k=;k<=n;k++)
f[j]=min(f[j],f[j-k]+a[i][k]);
cout<<f[n];
}