A. Numbers
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.
Now he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A?-?1.
Note that all computations should be done in base 10. You should find the result as an irreducible fraction, written in base 10.
Input
Input contains one integer number A (3?≤?A?≤?1000).
Output
Output should contain required average value in format ?X/Y?, where X is the numerator and Y is the denominator.
Sample test(s)
input
5
output
7/3
input
3
output
2/1
Note
进制相关
/* ***********************************************
Author :
Created Time :2015/6/8 19:15:10
File Name :5.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int gcd(int a,int b){
return a==0?b:gcd(b%a,a);
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int a,sum;
while(cin>>a){
sum=0;
for(int i=2;i<a;i++){
int t=a;
while(t>0){
sum+=(t%i);
t=t/i;
}
}
int k=gcd(a-2,sum);
printf("%d/%d\n",sum/k,(a-2)/k);
}
return 0;
}