//\\__ hr1212 __//\\
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%lld",&a)
#define sii(a,b) scanf("%lld %lld",&a,&b)
#define siii(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pi(a) printf("%lld\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 200100
#define MOD 1000000007
ll n,m,phi[MAX];
int main(){
ll r,k,i,c=0,x=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;string p;
phi[0]=0;
f(i,1,MAX)
phi[i]=i;
f(i,2,MAX){
if(phi[i]==i){
for(j=i;j<MAX;j+=i)
phi[j]=phi[j]/i*(i-1);
}
phi[i]+=phi[i-1];
}
while(si(n)!=EOF){
if(n==0)
break;
if(n==1){
printf("0/1\n");
continue;
}
if(n==2){
printf("1/1\n");
continue;
}
n--;
z=lower_bound(phi,phi+MAX,n)-phi;
m=n-phi[z-1];c=0;
f(i,1,z){
if(__gcd(i,z)==1){
c++;
if(c==m){
printf("%lld/%lld\n",i,z);
break;
}
}
}
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%lld",&a)
#define sii(a,b) scanf("%lld %lld",&a,&b)
#define siii(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pi(a) printf("%lld\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 200100
#define MOD 1000000007
ll n,m,phi[MAX];
int main(){
ll r,k,i,c=0,x=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;string p;
phi[0]=0;
f(i,1,MAX)
phi[i]=i;
f(i,2,MAX){
if(phi[i]==i){
for(j=i;j<MAX;j+=i)
phi[j]=phi[j]/i*(i-1);
}
phi[i]+=phi[i-1];
}
while(si(n)!=EOF){
if(n==0)
break;
if(n==1){
printf("0/1\n");
continue;
}
if(n==2){
printf("1/1\n");
continue;
}
n--;
z=lower_bound(phi,phi+MAX,n)-phi;
m=n-phi[z-1];c=0;
f(i,1,z){
if(__gcd(i,z)==1){
c++;
if(c==m){
printf("%lld/%lld\n",i,z);
break;
}
}
}
}
return 0;
}
No comments:
Post a Comment