P3414 SAC#1 - 组合数
组合数的性质,求(1<<(n-1))%mod即可。其实要快速幂。
#include<bits/stdc++.h> #define MOD 6662333 using namespace std; unsigned long long n; unsigned long long p(unsigned long long x) { unsigned long long t=2; while(x%2==0) { t*=t; t%=MOD; x>>=1; } unsigned long long result=1; while(x>0) { if(x%2==1) { result*=t; result%=MOD; } x>>=1; t*=t; t%=MOD; } return result%MOD; } int main() { cin>>n; n--; cout<<p(n); return 0; }
时间: 2024-12-28 10:50:07