The main topic: Beg Σ[i|n]i^d
Onlookers: http://www.cnblogs.com/jianglangcaijin/p/4033399.html
Sure enough, I'm still too konjac--
In addition, the 0 items of σ[1<=i<=n]i^m are destined to be 0--so the constant term does not have to be eliminated--
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 110# Define MOD 1000000007using namespace Std;long long D,w;long long F[m][m],a[m];long long H[m],ans;long long Quick_power (lon G long X,long long y) {long long re=1; (y+=mod-1)%= (MOD-1), while (y) {if (y&1) (re*=x)%=mod; (x*=x)%=mod;y>>=1;} return re;} void Gauss_elimination () {int i,j,k;for (i=1;i<=d+1;i++) {Long Long temp=i;for (j=1;j<=d+1;j++, (temp*=i)%=MOD) f[ I][j]=temp;for (j=1,temp=1;j<=d;j++, (temp*=i)%=mod);(f[i][d+2]= (i?f[i-1][d+2]:0) +temp)%=MOD;} for (i=1;i<=d+1;i++) {for (j=i;j<=d+1;j++) if (F[j][i]) break;for (k=1;k<=d+2;k++) swap (f[i][k],f[j][k]); j=i+1;j<=d+1;j++) {long temp=mod-f[j][i]*quick_power (f[i][i],-1)%mod;for (k=i;k<=d+2;k++) (F[j][k]+=f[i] [k]*temp)%=mod;}} for (i=d+2;i;i--) {for (j=i+1;j<=d+1;j++) (F[i][d+2]-=f[i][j]*a[j])%=mod;a[i]= (F[i][d+2]*quick_power (f[i][i],-1 )%mod+mod)%mod;} for (i=1;i<=d+1;i++)//cout<<a[i]<<endl;} int main () {int i,j;cin>>d>>w; Gauss_elimination (); for (j=1;j<=d+1;j++) h[j]=1;for (i=1;i<=w;i++) {int p,a;scanf ('%d%d ', &p,&a); for (j =1;j<=d+1;j++) (H[j]*=quick_power (p, (long Long) a*j)%mod * (1-quick_power (p,d-j)%mod)% MOD)%=mod;} For (j=1;j<=d+1;j++) (Ans+=a[j]*h[j])%=mod;cout<< (ans%mod+mod)%mod<<endl;return 0;}
Bzoj 36,011 person's number theory of the Mo-de-si inverse + Gaussian elimination