考虑推广sum(i in Z){mu^2(i)}的做法.

#include"roundCount.cpp"
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<primesieve.hpp>
namespace GPG{
typedef long long ll;
typedef bool B;
namespace Gauss{
#define opr(x,op) inline x operator op (
#define ret(...) ){return ({__VA_ARGS__;});}
#define AL2(x,y,z) x y,x z
#define vopr(x,op,y,z,...) opr(x,op) AL2(x,y,z) ret(__VA_ARGS__)
#define lbd(x,n) inline x n (
struct GI{
int a,b; // a+bi
GI():a(0),b(0){}
GI(int a,int b=0):a(a),b(b){}
};
lbd(ll,norm)GI a ret(a.a*a.a+a.b*a.b)
vopr(GI,+,a,b,GI(a.a+b.a,a.b+b.b))
vopr(GI,-,a,b,GI(a.a-b.a,a.b-b.b))
vopr(GI,*,a,b,GI(a.a*b.a-a.b*b.b,a.a*b.b+a.b*b.a))
opr(B ,<)AL2(GI,a,b)ret(norm(a)<norm(b)) } using namespace Gauss;
#define maxn 10000011
using namespace std;
char v[maxn];
vector<int> prs;
int ppp[10000010];
int nextPP[10001001];
int main(){
primesieve::generate_primes(10000000,&prs);
for(int i=0,_=prs.size();i<_;++i) v[prs[i]]=1;
for(int i=1,j=3162;i*i<=10000000;++i){
while(j && i*i+j*j>10000000)--j;
if(v[i]&&((i&3)==3))ppp[i*i]++;
for(int k=1;k<=j;++k) if(v[i*i+k*k]) ppp[i*i+k*k]++;
}
for(int i=1,last=0;i<=10000000;++i){
if(ppp[i]) nextPP[last]=i,last=i;
}
return 0;
}
} using namespace GPG;
namespace Combine{
int C[22][22];
inline void init_combine(){
C[0][0]=1;
for(int i=1;i<=20;++i){
C[i][0]=1;
for(int j=1;j<=i;++j) C[i][j]=C[i-1][j]+C[i-1][j-1];
}
}
} using namespace Combine;
#define threshold 100000000000000ll
#define thresholdsqrt 10000000ll /*
#define threshold 10000ll
#define thresholdsqrt 100ll
*/
inline ll dfs(int now,int nowexp,ll mul,ll tot,int mu){
// printf("%d %d %-4lld %-4lld %-3d\n",now,nowexp,mul,tot,mu);
ll ans=nowexp?tot*mu:0;
if(ans){
ans*=RC(threshold/mul/mul);
// printf("+ RC(%lld)=%lld\n",threshold/mul/mul,RC(threshold/mul/mul));
}
int v=nextPP[now];
if(!v || v*mul>thresholdsqrt) return ans;
ans+=dfs(v,0,mul,tot,mu);
for(int i=1;i<=ppp[v];++i){
mu=-mu;
if(double(mul)*v>double(thresholdsqrt))break;
mul*=v;
if(mul>thresholdsqrt)break;
ans+=dfs(v,i,mul,tot*C[ppp[v]][i],mu);
}
return ans;
}
int main(){
RCCC::init();
GPG::main();
Combine::init_combine();
printf("%lld\n",dfs(0,0,1,1,1)+RC(threshold));
return 0;
}

PE556的更多相关文章

随机推荐

  1. thinkphp传递参数

    php文件输出 U() 跳转地址, echo U('Index/index',array('uid'=>1,'username'=>'wang','time'=>165465121) ...

  2. thinkphp安装 版本 3.1.3

    基础版: 只有thinkphp基础运行功能 完整版:基础运行能力,还有图片.上传等各种处理类(建议下载完整版) 重要的三个变量 define('APP_DEBUG',True); // 定义应用目录d ...

  3. Mac安装Brew

    安装命令如下:curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip ...

  4. JAVA GUI随笔

    Java的布局管理器提供了一种层面的抽象,自动将用户界面映射到所有的窗口系统.GUI组件放置在容器中,它们的位置由容器的布局管理器来管理. 布局管理器是使用布局管理器类创建的. 注:同一个对象无论添加 ...

  5. ASP.NET MVC URL重写与优化(进阶篇)-继承RouteBase玩转URL

    http://www.cnblogs.com/John-Connor/archive/2012/05/03/2478821.html 引言-- 在初级篇中,我们介绍了如何利用基于ASP.NET MVC ...

  6. APP抓链接工具(Fiddler版)

    1.下载Fiddler源代码: http://pan.baidu.com/s/1hqEUK0O 2.修改如下源代码: 3.运行截图:

  7. 开源项目管理平台*redmine*的架设

    yum -y install ruby yum install rubygems gem install heroku gem install rack -v=1.0.1 gem install ru ...

  8. Loader Generator---loading图片生成器

    if(公司配有专业的设计师) return; Recommend("http://loadergenerator.com/");

  9. kafka+zookeeper环境配置(Mac 或者 linux环境)

    一.zookeeper下载与安装 1)下载 adeMacBook-Pro:zookeeper_soft apple$ wget http://mirrors.cnnic.cn/apache/zooke ...

  10. php中关于 left join 的分页显示

    /* * 统计商机搜索总条数信息 * ftt * 2015-11-10 10:13:15 */ public function getBusinessCount($btype='',$buname=' ...