考虑推广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. C#----使用WindowsMediaPlayer 同时播放多个声音

    使用Windows Media Player 其实就是使用组件AxWindowsMediaPlayer. 添加两个引用:Interop.WMPLib.dll和AxInterop.WMPLib.dll. ...

  2. python的简洁是shell无法代替的

    之前线上服务器分发配置都是用shell和expect脚本分发,脚本写了很长,上周换了ansible,现在自己用python写一个,就30行代码就可以实现需求,之前的shell写了快200行了,蛋疼,代 ...

  3. Comet、SSE、技术

    1.概念: 利用长时间保留的HTTP请求(‘挂起的GET’)来让服务器向浏览器推送数据的技术,经常被称为Comet. SSE让服务器可以向客户端流式发送文本消息,比如服务器上生成的实时通知或更新.

  4. C# C++联调

    http://jingyan.baidu.com/article/fcb5aff7926344edab4a714d.html

  5. ecshop 活动-》红包

    按商品发放:可以给指定某个商品发红包(购买付款,卖家发货后,会自动给买家发送红包:不是买家在付款的时候就自动可以减少红包金额) 按订单金额发放:订单满xx后(卖家发货后,会自动给买家发放红包)

  6. live555库中的testRTSPClient实例

    1.testRTSPClient简介 testRTSPClient是个简单的客户端实例,这个实例对rtsp数据交互作了详细的描述,其中涉及到rtsp会话的两个概念Source和Sink. Source ...

  7. <?xml version="1.0" encoding="utf-16"?>. use different encoding

    public string Serialize<T>(T serializeClass) { string xmlString = string.Empty; try { if (seri ...

  8. C# 对象 序列化 XML

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  9. [c#]获取exchange中的图片

    摘要 在exchange 2007或者2010中获取的邮件内容为html标签格式,也就是一个页面.如果里面含有img标签,你会发现img标签的src属性为cid:xxxxxxxxxxxx的一串字符串, ...

  10. uname是什么?

    uname= unix +name, 是指unix 这个操作系统的 名字, 包括 主机名, 内核版本 架构 平台名称等等