您的位置:首页 > 其它

13A - Numbers

2016-07-21 20:36 417 查看
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.

Examples

input
5


output
7/3


input
3


output
2/1


Note

In the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively.

给出一个n,计算用2~n-1进制表示n时,所有位上的数字的和。

本以为会有什么比较好的方法,后来想想,暴力吧,然后..水过了....

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int val(int x,int base)
{
int ans=0;
while(x)
{
ans+=x%base;
x/=base;
}
return ans;
}
int main()
{
int n,ans=0;
scanf("%d",&n);
for(int i=2;i<n;++i)
{
ans+=val(n,i);
}
n-=2;
int tp=__gcd(ans,n);
printf("%d/%d\n",ans/tp,n/tp);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: