poj 3761 bubble sort (排列组合)
#include<cstdio> #include<cstring> #define ll long long #define mod 20100713 const int maxn=1000005; ll a[maxn]; ll poww(ll x,int n) { ll ret=1; while(n) { if(n&1) ret=ret*x%mod; n>>=1; x=x*x%mod; } return ret; } int main() { a[0]=1; for(int i=1;i<maxn;i++) a[i]=a[i-1]*i%mod; int T; scanf("%d",&T); while(T--) { int n,k; scanf("%d%d",&n,&k); ll ans=a[k]*(poww(k+1,n-k)-poww(k,n-k)+mod)%mod; printf("%lld\n",ans); } return 0; }