首页 > 其他 > 详细

bzoj1041 [HAOI2008]圆上的整点

时间:2017-12-17 17:28:06      阅读:245      评论:0      收藏:0      [点我收藏+]

隐藏在素数规律中的π

传送门

技术分享图片
//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
const int N=5e4+7;
typedef long long LL;
using namespace std;
int tot;
LL n,p[N],c[N],ans=1;

template<typename T> void read(T &x) {
    char ch=getchar(); T f=1; x=0;
    while(ch!=-&&(ch<0||ch>9)) ch=getchar();
    if(ch==-) f=-1,ch=getchar();
    for(;ch>=0&&ch<=9;ch=getchar()) x=x*10+ch-0; x*=f;
}

int main() {
    read(n);
    LL tp=n;
    int nn=sqrt(n);
    for(int i=2;i<=nn;i++) {
        if(tp%i==0) {
            p[++tot]=i;
            while(tp%i==0) {
                c[tot]++;
                tp/=i;
            }
        }
    }
    if(tp!=1) {
        p[++tot]=tp;
        c[tot]=1;
    }
    for(int i=1;i<=tot;i++) {
        if(p[i]==2) continue;
        if(p[i]%4==1) ans*=LL(c[i]*2+1);
    }
    printf("%lld\n",ans*4);
    return 0;
}
View Code

 

bzoj1041 [HAOI2008]圆上的整点

原文:http://www.cnblogs.com/Achenchen/p/8052455.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!