[数位DP] BZOJ 3209 花神的数论题
来源:互联网 发布:阿里云网站空间误删 编辑:程序博客网 时间:2024/06/05 08:36
求出有i个1的数有多少
然后快速幂
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std; typedef long long ll; const int N=100005; const int M=255; const int P=10000007; ll a[N],len,n; ll C[M][M]; inline void Pre(){ for(int i=0;i<60;i++){ C[i][0]=1; for(int j=1;j<=i;j++)C[i][j]=C[i-1][j]+C[i-1][j-1];} } inline ll Solve(ll k){ ll ans=0; for(ll i=len;i>=1;i--){ if(a[i])ans+=C[i-1][k],k--;if(k<0) return ans; }return ans; } inline ll Pow(ll a,ll b){ll ret=1; a%=P;for (;b;b>>=1,a=a*a%P)if (b&1)ret=ret*a%P;return ret;} int main() {Pre(); scanf("%lld",&n);n++; len=0;while (n) a[++len]=n%2,n>>=1;ll ans=1; for(int i=1;i<=len;i++) ans=ans*Pow(i,Solve(i))%P; printf("%lld\n",ans);return 0; }
0 0
- [数位dp] bzoj 3209 花神的数论题
- BZOJ 3209 花神的数论题 数位DP+数论
- BZOJ 3209 花神的数论题 数位DP
- BZOJ 3209 花神的数论题 (数位DP)
- bzoj 3209 花神的数论题(数位dp)
- bzoj 3209: 花神的数论题 数位dp
- [数位DP] BZOJ 3209 花神的数论题
- BZOJ 3209: 花神的数论题 (数位dp)
- bzoj 3209: 花神的数论题 (数位DP)
- BZOJ 3209: 花神的数论题 数位DP
- BZOJ 3209 花神的数论题 数位dp
- [BZOJ]3209: 花神的数论题 数位DP
- HYSBZ 3209 花神的数论题(数位dp)
- BZOJ3209 花神的数论题(数位dp)
- 【bzoj3209】【花神的数论题】【数位dp+快速幂】
- [BZOJ3209]花神的数论题(数位dp)
- bzoj3209 花神的数论题 数位DP
- BZOJ 3209(花神的数论题-数位统计+1,被数据范围坑了)
- scss进阶教程
- 人数不定的工资类
- DownLoadManager 的使用
- 将zabbix数据库从innodb迁移到tokudb并分区
- centos VBoxLinuxAdditions 安装报错 Building the main Guest Additions module
- [数位DP] BZOJ 3209 花神的数论题
- Android ORM框架介绍之greenDao配置(一)
- spring data MongoDB分页
- 文章标题
- [树形DP || 贪心] BZOJ 1907 树的路径覆盖
- Python新建文件夹并以当前时间命名
- 自己优化过的RSA非对称加密算法
- connect函数详解
- LeetCode: Set Matrix Zeroes