1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| #include<algorithm> #include<iostream> #include<iomanip> #include<cstring> #include<cstdlib> #include<complex> #include<vector> #include<cstdio> #include<cmath> #include<map> using namespace std; typedef long long LL; inline const LL Get_Int() { LL num=0,bj=1; char x=getchar(); while(x<'0'||x>'9') { if(x=='-')bj=-1; x=getchar(); } while(x>='0'&&x<='9') { num=num*10+x-'0'; x=getchar(); } return num*bj; } char x1; const int maxn=200005; int t,cnt=0,vst[maxn],Prime[maxn]; char x2; LL Quick_Pow(LL a,LL b,LL mod) { LL ans=1; while(b>0) { if(b&1)ans=ans*a%mod; b>>=1; a=a*a%mod; } return ans; } int Work(int n,int p) { LL ans=0; while(n) { ans+=n/p; n/=p; } return ans; } int Solve(int n,int m,int p) { LL ans=1; for(int i=1; i<=cnt&&Prime[i]<=n; i++) { LL x=Work(n,Prime[i]),y=Work(n-m,Prime[i]),z=Work(m,Prime[i]); x-=y+z; ans=ans*Quick_Pow(Prime[i],x,p)%p; } return ans; } void Prime_Table(int n) { for(int i=2; i<=n; i++) { if(!vst[i])Prime[++cnt]=i; for(int j=1; j<=cnt&&Prime[j]*i<=n; j++) { vst[Prime[j]*i]=1; if(i%Prime[j]==0)break; } } } int main() { Prime_Table(200000); LL a=Get_Int(),b=Get_Int(); printf("%lld\n",Solve(a+b-1,b,20080814)); return 0; }
|