代码:
#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 ;
}