3209: 花神的数论题

Time Limit: 10 Sec  Memory Limit: 128 MB
Submit: 2498  Solved: 1129
[Submit][Status][Discuss]

Description

背景
众所周知,花神多年来凭借无边的神力狂虐各大 OJ、OI、CF、TC …… 当然也包括 CH 啦。
描述
话说花神这天又来讲课了。课后照例有超级难的神题啦…… 我等蒟蒻又遭殃了。
花神的题目是这样的
设 sum(i) 表示 i 的二进制表示中 1 的个数。给出一个正整数 N ,花神要问你
派(Sum(i)),也就是 sum(1)—sum(N) 的乘积。

Input

一个正整数 N。

Output

一个数,答案模 10000007 的值。

Sample Input

样例输入一

3

Sample Output

样例输出一

2

HINT

对于样例一,1*1*2=2;

数据范围与约定

对于 100% 的数据,N≤10^15

Source

原创 Memphis

枚举1的个数,组合数+快速幂即可。

 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define mod 10000007
#define LL long long
using namespace std;
LL c[][];
void pre() {
for(int i=;i<=;i++) c[i][]=;
for(int i=;i<=;i++) for(int j=;j<=i;j++) c[i][j]=c[i-][j]+c[i-][j-];
}
LL w[];
LL n,len;
LL power(LL a,LL b) {
LL ans=;
while(b) {
if(b&) ans*=a,ans%=mod;
a*=a;a%=mod;
b>>=;
}
return ans;
}
LL cnt(LL x) {
LL ans=;
for(int i=len;i>=;i--) {
if(w[i]) ans+=c[i-][x],x--;
if(x<) break;
}
return ans;
}
int main() {
pre();
scanf("%lld",&n);
n++;
while(n) {
w[++len]=n&;
n>>=;
}
LL ans=1LL;
for(int i=;i<=len;i++) ans*=power(i,cnt(i)),ans%=mod;
printf("%lld",ans);
}

最新文章

  1. .NET深入实战系列—Linq to Sql进阶
  2. espcms特殊标签
  3. C++ 利用 libxl 将 Excel 文件转化为 Xml 文件
  4. jquery-1.3.2.js
  5. SharePoint Foundation 2013 with SP1
  6. Match:Blue Jeans(POJ 3080)
  7. JSTL 的 if else : 有 c:if 没有 else 的处理
  8. 转载:奇异值分解(SVD) --- 线性变换几何意义(下)
  9. google proto buffer安装和简单示例
  10. TSQL基础(二)
  11. RHCA442学习笔记-Unit10内存地址及分配
  12. ARM开发板系统移植-----kernel的编译
  13. 高健壮性css---Float详细
  14. [实验]通过内核Patch去掉iOS-v4.3.3的沙盒特性
  15. 覆盖问题&lt;shui&gt;
  16. Servlet 详解
  17. ppt制作元素采集
  18. python学习(十一)
  19. linux系统常用的基本命令分类
  20. tcp_协议基础

热门文章

  1. 【题解】ZJOI2013蚂蚁寻路
  2. UDP收/发广播包原理及步骤
  3. 移动端H5滚动穿透解决方案
  4. Linux shell命令无法使用
  5. Spring Framework框架解析(1)- 从图书馆示例来看xml文件的加载过程
  6. Java并发(5)- ReentrantLock与AQS
  7. bzoj 4999: This Problem Is Too Simple!
  8. 【比赛】百度之星2017 初赛Round B
  9. 河南省第十届省赛 Binary to Prime
  10. hdu 3003 Pupu