bzoj1041 [HAOI2008]圆上的整点

隐藏在素数规律中的π

传送门

//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

 

posted @ 2017-12-17 16:26  啊宸  阅读(174)  评论(0编辑  收藏  举报