zoukankan      html  css  js  c++  java
  • 华华给月月出题

    题目链接

    注意到x^n是个积性函数就能做了,然后就是一波线性筛素数+快速幂的操作

    #include <bits/stdc++.h>
    using namespace std;
    #define re register
    #define ll long long
    const int mod=1e9+7;
    const int maxn=1.3*10000000;
    void read(int &a)
    {
        a=0;
        int d=1;
        char ch;
        while(ch=getchar(),ch>'9'||ch<'0')
            if(ch=='-')
                d=-1;
        a=ch-'0';
        while(ch=getchar(),ch>='0'&&ch<='9')
            a=a*10+ch-'0';
        a*=d;
    }
    void write(int x)
    {
        if(x<0)
            putchar(45),x=-x;
        if(x>9)
            write(x/10);
        putchar(x%10+'0');
    }
    int vis[maxn],p[maxn];
    int quickmod(int x,int y)
    {
        int result=1;
        int base=x;
        while(y)
        {
            if(y&1)
                result=1ll*result*base%mod;
            base=1ll*base*base%mod;
            y>>=1;
        }
        return result;
    }
    int main()
    {
        int n;
        read(n);
        int ans=1,cnt=1;
        for(re int i=2;i<=n;i++)
        {
            if(!vis[i])
                p[cnt++]=i,vis[i]=quickmod(i,n);
            for(re int j=1;j<=cnt&&p[j]*i<=n;j++)
            {
                vis[i*p[j]]=1ll*vis[i]*vis[p[j]]%mod;
                if(i%p[j]==0)
                    break;
            }
            ans^=vis[i];
        }
        write(ans);
        return 0;
    }
    View Code
  • 相关阅读:
    10046 event 知多少
    10046 event 知多少
    awr相关指标解析
    父子关系展示
    secureCRT启动xmanager图形化工具
    linux单用户模式
    Tor
    windows下的unix工具集:UnxUtils
    OPENLDAP
    Windows命令行重命名文件
  • 原文地址:https://www.cnblogs.com/acm1ruoji/p/10668216.html
Copyright © 2011-2022 走看看