2019.2.14 t1 最大公约数
2024-08-25 11:15:41
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <vector>
using namespace std; #define LL long long
#define res register long long
inline LL read()
{
LL x(),f(); char ch;
while(!isdigit(ch=getchar())) if(ch=='-') f=-;
while(isdigit(ch)) x=x*+ch-'',ch=getchar();
return f*x;
}
LL s[],tot;
LL b[],cnt;
inline void pre_work(LL n)
{
//质因数
LL tmp=n;
for(res i= ; i*i<=n ; i++)
{
if(n%i==) s[++tot]=i;
while(n%i==) n/=i;
}
if(n>) s[++tot]=n;
//约数
for(res i= ; i*i<=tmp ; i++)
if(tmp%i==)
{
b[++cnt]=i;
if(i!=tmp/i) b[++cnt]=tmp/i;
}
} LL phi(LL n)
{
LL ans=n;
for(res i= ; i<=tot ; i++)
{
if(n%s[i]==)
ans=ans/s[i]*(s[i]-);
}
return ans;
} int main()
{
// freopen("gcd.in","r",stdin);
// freopen("gcd.out","w",stdout);
LL n;
n=read();
pre_work(n);
sort(b+,b+cnt+);
for(res i= ; i<=cnt ; i++)
{
cout<<b[i]<<" ";
cout<<phi(n/b[i])<<endl;
}
return ;
}
最新文章
- 控制Storyboard播放zz
- Nand Flash,Nor Flash,CFI Flash,SPI Flash 之间的关系
- Oracle10g在Win2008R2下因版本无法安装问题的解决
- XP共享连接数限制
- Swift实战-QQ在线音乐(第二版)
- Server.Transfer和Response.Redirect区别
- Android 显示原理简介
- Oracle数据库还原方法
- c# base和this在构造函数中的应用
- thinkphp之获取客户端IP地址
- Swift中集合类型indexOf(Element)提示错误的解决办法
- 【LUOGU???】WD与积木 NTT
- Gin框架源码解析
- python下载及安装
- python中requests已安装却仍报No module named requests错的原因
- shell脚本的基本结构以及如何执行
- Nodejs【单机】多进程模式集群
- [转载]oracle的常用函数 instr() 和substr()函数
- Final阶段贡献分配规则及实施
- Unused Method(不再使用的方法)——Dead Code(死亡代码)
热门文章
- 76-Relatives-欧拉函数
- Openssl ec命令
- python 多继承详解-乾颐堂
- linux环境下搭建osm_web服务器四(对万国语的地名进行翻译和检索):
- Red Hat 6.5 Samba服务器的搭建(登录访问)
- [SoapUI] 比较两个不同环境下XML格式的Response, 结果不同时设置Test Step的执行状态为失败
- log4j-over-slf4j工作原理详解
- Golang 之 Qrcode 二维码
- Mac os安装DVWA环境教程
- [GO]runtime包及gosched的使用