考虑推广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. 一种nodejs的MVC框架

    mvc会针对请求进行分发,分发一般有controller(针对模块),action(针对模块中的方法),args(请求的参数). 1.先对http请求的url进行设置,解析url中的各种参数: //c ...

  2. Light Pre-Pass相关链接

    Key Words: Light Pre-Pass, Deferred Lighting http://mquandt.com/blog/2010/03/light-pre-pass-round-2/ ...

  3. Visual Studio Code 怎么支持中文

    这其实是编码问题 和字体什么的没有关系,在VSCode中默认是用UTF-8编码方式打开文件,只要你的文件是这个编码就能正常打开如果不是,不进行设置VSCode是不会自动切换编码方式打开 手动可以Reo ...

  4. C#和SQL实现的字符串相似度计算代码分享

    http://www.jb51.net/article/55941.htm C#实现: 复制代码 代码如下: #region 计算字符串相似度        /// <summary>   ...

  5. servlet中的相对路径和绝对路径 及/, ./, ../的区别

    ./ 当前目录../ 父级目录/ 根目录资源寻找都是依靠路径,资源存储方式是按照哈希表运算的,所以路径的计算其实就是哈希值的计算. servlet中,所有路径的配置都要用绝对路径. 什么是绝对路径,就 ...

  6. maven 入门

    Apache Maven 入门篇 ( 上 ) 作者:George Ma 写这个 maven 的入门篇是因为之前在一个开发者会的动手实验中发现挺多人对于 maven 不是那么了解,所以就有了这个想法.这 ...

  7. SICP— 第一章 构造过程抽象

    SICP  Structure And Interpretation Of Computer Programs 中文第2版 分两部分  S 和 I 第一章 构造过程抽象 1,程序设计的基本元素 2,过 ...

  8. 【AngularJS】—— 4 表达式

    前面了解了AngularJS的基本用法,这里就跟着PDF一起学习下表达式的相关内容. 在AngularJS中的表达式,与js中并不完全相同. 首先它的表达式要放在{{}}才能使用,其次相对于javas ...

  9. 湖南附中模拟day1 瞭望塔

    /* 这个题要用到树的性质,一般比较难的图论题会往这方面靠拢,这样用很容易出错,应该先写暴力,然后再去一点点想正解 */ //暴力70分 #include<iostream> #inclu ...

  10. 机器学习之Hash集合问题

    问题来源与七月学习之 (3.x线性代数与矩阵运算基础)