https://minamoto.blog.luogu.org/solution-p5106

容易想到枚举质因子及其次数计算其贡献,容斥计算$\varphi(p^i)$的次方数。

 #include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std; const int N=,mod=1e9+;
int n,k,tot,ans,b[N],p[N]; int ksm(int a,int b,int mod){
int res=;
for (; b; a=1ll*a*a%mod,b>>=)
if (b & ) res=1ll*res*a%mod;
return res;
} void init(){
rep(i,,n){
if (!b[i]) p[++tot]=i;
for (int j=; j<=tot && i*p[j]<=n; j++){
b[i*p[j]]=;
if (i%p[j]==) break;
}
}
} int D(ll pi,ll pi1){
int s1=ksm(n-n/pi,k,mod-),s2=ksm(n-n/pi1,k,mod-);
return (s1-s2+mod-)%(mod-);
} int main(){
scanf("%d%d",&n,&k); init(); ans=;
rep(i,,tot)
for (ll t=p[i]; t<=n; t*=p[i])
ans=1ll*ans*ksm(t-t/p[i],D(t*p[i],t),mod)%mod;
printf("%d\n",ans);
return ;
}

[Luogu5106]dkw的lcm的更多相关文章

  1. P5106 dkw的lcm

    传送门 终于A了--细节真多-- 首先我们发现这是个连乘,而且\(\phi\)是个积性函数,所以我们可以考虑不同的质因子以及它的不同次数的贡献.简单来说就是把每一次的\(\phi(lcm(i_1,i_ ...

  2. [洛谷P5106]dkw的lcm:欧拉函数+容斥原理+扩展欧拉定理

    分析 考虑使用欧拉函数的计算公式化简原式,因为有: \[lcm(i_1,i_2,...,i_k)=p_1^{q_{1\ max}} \times p_2^{q_{2\ max}} \times ... ...

  3. LCM性质 + 组合数 - HDU 5407 CRB and Candies

    CRB and Candies Problem's Link Mean: 给定一个数n,求LCM(C(n,0),C(n,1),C(n,2)...C(n,n))的值,(n<=1e6). analy ...

  4. CodeBlocks及LCM应用

    以下是在开发过程中遇到的一些细节点: 1)called after throwing an instance of std::bad_alloc 此问题是由于publish(data),当中data赋 ...

  5. LCM 轻量级通信组件

    LCM和ZMQ比较 http://www.doc88.com/p-6711552253536.html 基于LCM和ZeroMQ的进程间通信研究 2.简介 LCM(Lightweight Commuc ...

  6. uva12546. LCM Pair Sum

    uva12546. LCM Pair Sum One of your friends desperately needs your help. He is working with a secret ...

  7. UVA 10791 Minimum Sum LCM(分解质因数)

    最大公倍数的最小和 题意: 给一个数字n,范围在[1,2^23-1],这个n是一系列数字的最小公倍数,这一系列数字的个数至少为2 那么找出一个序列,使他们的和最小. 分析: 一系列数字a1,a2,a3 ...

  8. LCM在Kernel中的代码分析

    lcm的分析首先是mtkfb.c 1.mtk_init中platform_driver_register(&mtkfb_driver)注册平台驱动 panelmaster_init(); DB ...

  9. Pairs Forming LCM(素因子分解)

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=109329#problem/B    全题在文末. 题意:在a,b中(a,b<=n) ...

随机推荐

  1. 快速修改Matlab默认启动路径(Windows/Mac)

    如何修改Matlab启动路径/Windows or Mac 控制台内输入一下两行命令,之后重启MATLAB即可   newpath = '你所要设定的路径'; userpath(newpath)   ...

  2. vi的复制粘贴命令 -- (转)

    vi编辑器有3种模式:命令模式.输入模式.末行模式.掌握这三种模式十分重要: 1.命令模式:vi启动后默认进入的是命令模式,从这个模式使用命令可以切换到另外两种模式,同时无论在任何模式下只要按一下[E ...

  3. 在linux上安装完oracle数据库后,如何修改ORACLE_HOSTNAME

    1.修改HOSTS文件,添加node2到本机IP地址的映射: [root@node2home]# gedit /etc/hosts 最后一行为添加的: 127.0.0.1 localhost loca ...

  4. 使用java8的StreamAPI对集合计算进行代码重构

    方法: 查询出所有部门成员中年龄大于30的员工姓名 部门对象: 员工对象: 模拟数据: private static List<Dept> list=new ArrayList<De ...

  5. Html.DropDownListFor() 二级联动 ($.getJSON)

    Control: public ActionResult GetPositionName(int parentid) //发布新职位页面中的根据职位类别,获取职位名称 { List<Catego ...

  6. Add custom daemon on Linux System

    Ubuntu add custom service(daemon) Task 需要在系统启动的时候自动启动一个服务(后台程序),在系统关闭的时候关闭服务. 比如在部署某个应用之前,需要将某个任务设置成 ...

  7. 二、springboot配置

    一.启动类 在包根目录下添加启动类,必须包含main方法,再添加Spring Boot启动方法: SpringApplication.run(SampleController.class, args) ...

  8. @RequestParam,@PathParam,@PathVariable,@QueryParam注解的使用区别

    获取url模板上数据的(/{id})@DefaultValue 获取请求参数的(包括post表单提交)键值对(?param1=10&param2=20).可以设置defaultValue JA ...

  9. 【小程序开发】上拉加载更多demo

    wxml: <scroll-view class='swiper-scroll' scroll-y="{{true}}" bindscrolltolower="lo ...

  10. KVM virsh常用命令篇

    1.查看运行的虚拟机 virsh list 2.查看所有的虚拟机(关闭和运行的虚拟机) virsh list --all 3.连接虚拟机 virsh console +域名(虚拟机的名称) 4.退出虚 ...