Luogu-P5221 Product


Product





图片说明


#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
#define sc scanf
#define itn int
#define STR clock_t startTime = clock();
#define END clock_t endTime = clock();cout << double(endTime - startTime) / CLOCKS_PER_SEC *1000<< "ms" << endl;
using namespace std;
const int N=1e6+5;
const int mod=104857601;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}
inline ll ksm(ll a,ll b,ll c){ll ans=1;for(;b>0;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}
inline void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=x*(a/b);}
int phi[N];
int main(){
    for(int i=1;i<N;i++)phi[i]=i;
    for(int i=2;i<N;i++){
        if(phi[i]==i){
            for(int j=i;j<N;j+=i){
                phi[j]=phi[j]/i*(i-1);
            }
        }
    }
    int pos=0;bool f=0;
    for(int i=1;i<N;i++){
        ll x=1LL*phi[i]+phi[i-1];
        if(x>=mod-1){
            if(!f)pos=i,f=1;
            x%=mod-1;
        }
        phi[i]=x;
    }
    int n;sc("%d",&n);
    ll prod=1;
    for(int i=1;i<=n;i++){
        prod*=i;
        if(prod>=mod){
            prod%=mod;
        }
    }
    prod=ksm(prod,2*n,mod);
    ll res=1;
    for(int i=1;i<=n;i++){
        ll x=2LL*phi[n/i]-1;
        if(n/i>=pos)x+=mod-1;
        res*=ksm(i,x,mod);
        if(res>=mod)res%=mod;
    }
    res=res*res%mod;res=ksm(res,mod-2,mod);
    prod=prod*res%mod;
    printf("%lld\n",prod);
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
# 春招至今,你的战绩如何? #
6285次浏览 59人参与
# 你的实习产出是真实的还是包装的? #
1278次浏览 30人参与
# 米连集团26产品管培生项目 #
4669次浏览 206人参与
# 军工所铁饭碗 vs 互联网高薪资,你会选谁 #
7066次浏览 37人参与
# 简历第一个项目做什么 #
31317次浏览 315人参与
# 当下环境,你会继续卷互联网,还是看其他行业机会 #
186517次浏览 1115人参与
# 巨人网络春招 #
11208次浏览 223人参与
# 研究所笔面经互助 #
118783次浏览 577人参与
# 面试紧张时你会有什么表现? #
30416次浏览 188人参与
# 简历中的项目经历要怎么写? #
309555次浏览 4162人参与
# 职能管理面试记录 #
10722次浏览 59人参与
# AI时代,哪些岗位最容易被淘汰 #
62679次浏览 745人参与
# 网易游戏笔试 #
6371次浏览 83人参与
# 把自己当AI,现在最消耗你token的问题是什么? #
6982次浏览 154人参与
# 腾讯音乐求职进展汇总 #
160429次浏览 1106人参与
# 从哪些方向判断这个offer值不值得去? #
56712次浏览 357人参与
# 正在春招的你,也参与了去年秋招吗? #
362721次浏览 2631人参与
# 你怎么看待AI面试 #
179403次浏览 1181人参与
# 小红书求职进展汇总 #
226896次浏览 1356人参与
# 你的房租占工资的比例是多少? #
92144次浏览 896人参与
# 校招笔试 #
467547次浏览 2954人参与
# 经纬恒润求职进展汇总 #
155712次浏览 1085人参与
牛客网
牛客网在线编程
牛客网题解
牛客企业服务