传送门

分析

我们知道

$\varphi * 1 = id$

$\mu * 1 = e$

杜教筛即可

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<unordered_map>
using namespace std;
const int N = 5e6;
unordered_map<int,long long>phi;
unordered_map<int,int>mu;
unordered_map<int,bool>visp,vism;
long long _p[N+];
int _m[N+];
int cnt,p[N];
bool is[N+];
inline long long get_phi(int x){
if(x<=N)return _p[x];
if(visp[x])return phi[x];
long long res=(long long)x*(x+)/;
int le=,ri;
for(;le<=x;le=ri+){
ri=x/(x/le);
res-=(ri-le+)*get_phi(x/le);
}
visp[x]=;return phi[x]=res;
}
inline int get_mu(int x){
if(x<=N)return _m[x];
if(vism[x])return mu[x];
int res=,le=,ri;
for(;le<=x;le=ri+){
ri=x/(x/le);
res-=(ri-le+)*get_mu(x/le);
}
vism[x]=;return mu[x]=res;
}
inline void go(){
register int i,j,k;
_p[]=_m[]=;
for(i=;i<=N;++i){
if(!is[i])p[++cnt]=i,_m[i]=-,_p[i]=i-;
for(j=;j<=cnt,i*p[j]<=N;++j){
is[p[j]*i]=;
if(i%p[j]==){
_m[i*p[j]]=;
_p[i*p[j]]=_p[i]*p[j];
break;
}
_m[i*p[j]]=-_m[i];
_p[i*p[j]]=_p[i]*(p[j]-);
}
}
for(i=;i<=N;++i)_p[i]+=_p[i-],_m[i]+=_m[i-];
}
int main(){
int n,t;
scanf("%d",&t);
go();
while(t--){
scanf("%d",&n);
printf("%lld %d\n",get_phi(n),get_mu(n));
}
return ;
}

最新文章

  1. nginx 虚拟主机配置
  2. 谷毅(WingKu)横空出世
  3. Android annotations REST
  4. Android HandlerThread 的使用及其Demo
  5. vs2010工具栏 不显示dx控件
  6. python概要
  7. UNIX网络编程——网络数据包检测
  8. 就这样CSDN账号被人盗了??
  9. 使用VSCode 编译调试QT程序
  10. Android 使用EventBus发送消息接收消息
  11. Problem C: Pie
  12. 【Unity Shader实战】卡通风格的Shader(一)
  13. redis持久化详述
  14. Mybatis关联查询之一对多和多对一XML配置详解
  15. python第三方包安装方法(两种方法)
  16. [微信开发] 微信JSAPI - 获取用户地理位置信息
  17. 【react】---手动封装一个简易版的redux---【巷子】
  18. CSS 分类 选择器
  19. 洛谷P4549裴蜀定理
  20. E/MediaPlayer: start called in state 4, mPlayer(0xcc719a40)解决

热门文章

  1. jstat 简介(1)
  2. @angular/cli项目构建--路由1
  3. poj2336
  4. POJ - 3150 :Cellular Automaton(特殊的矩阵,降维优化)
  5. Python之高级库socketserver
  6. 快速构建一个 Springboot
  7. springmvc 加载静态文件失败
  8. 如果有多个集合的迭代处理情况【使用MAP】
  9. 蓝桥杯 算法训练 ALGO-141 P1102
  10. Order By操作