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

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.

#include "stdio.h"
#include "string.h"
#include "stdlib.h" int n;
int ntable[1000] ;
int su(int d,int n)
{int i=0,sum=0;
int r[1000];memset(r,0,100);
int tmp;
int l;
while(d!=0)
{tmp=d%n;
r[i]=ntable[tmp];
i++;
d/=n;
}
l=i;
for(i=0;i<l/2;i++)
{tmp=r[i];
r[i]=r[l-i-1];
r[l-i-1]=tmp;
}
for(i=0;i<l;i++)
sum+=r[i];
return sum;
} int gcd(int a,int b){
int r;
while(b>0){
r=a%b;
a=b;
b=r;
}
return a;
} int main( )
{
int a,i=0,ans,fm=0;
for(i=0;i<1000;i++)
{
*(ntable+i)=i;
}
while(~ scanf( "%d",&a ))
{
fm=a-1;ans=0;
for(i=2;i<=fm;i++)
{
ans+=su(a,i) ;
}
printf( "%d/%d\n",ans/gcd(ans,fm-1),(fm-1)/gcd(ans,fm-1) );
}
return 0;
}

codeforce - 13A A.Numbers的更多相关文章

  1. codeforce 600A - Extract Numbers

    学习string #include <bits/stdc++.h> #define eps 1e-8 #define M_PI 3.141592653589793 ; using name ...

  2. codeforce round#466(div.2)C. Phone Numbers

    C. Phone Numbers time limit per test2 seconds memory limit per test256 megabytes inputstandard input ...

  3. Codeforce 9C - Hexadecimal's Numbers

    One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got ...

  4. codeforces 630C Lucky Numbers

    C. Lucky Numbers time limit per test 0.5 seconds memory limit per test 64 megabytes input standard i ...

  5. 解题报告:codeforce 7C Line

    codeforce 7C C. Line time limit per test1 second memory limit per test256 megabytes A line on the pl ...

  6. Two progressions CodeForce 125D 思维题

    An arithmetic progression is such a non-empty sequence of numbers where the difference between any t ...

  7. CodeForce 577B Modulo Sum

    You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choo ...

  8. CodeForce 176C Playing with Superglue

    Two players play a game. The game is played on a rectangular board with n × m squares. At the beginn ...

  9. CodeForce 222C Reducing Fractions

    To confuse the opponents, the Galactic Empire represents fractions in an unusual format. The fractio ...

随机推荐

  1. jenkins自动化部署项目9 --定时构建

    举几个例子:每隔5分钟构建一次H/5 * * * * 每两小时构建一次H H/2 * * * 每天中午12点定时构建一次H 12 * * * 每天下午18点定时构建一次H 18 * * * 在每个小时 ...

  2. NABCD分析 [团队任务]

    N(Need,需求) 学校有许多闲置的自己用不着或者想出手的二手物品,加群发消息寻找物品太过繁琐,同样兼职信息在QQ群混杂在一起尤为不便.因此我们打算做一个专门发布信息的App.包括发布闲置物品,兼职 ...

  3. linux常用开发命令总结

    linux常用命令 文件操作命令 1. cd 目录名/目录名  切换目录 cd .. 切换到上一级目录  (change dictionary) Ctrl+C强制退出命令行,回到上一级 2.ls    ...

  4. .Net Core 商城微服务项目系列(八):购物车

    最近加班有点多,一周五天,四天加班到11点+,心很累.原因是我当前在的这个组比较特殊,相当于业务的架构组,要为其它的开发组提供服务和监控.所以最近更新的也少,不过这个元旦三天假应该会更新三篇. 这篇是 ...

  5. 手把手教你如何在Windows下allure与jenkins的集成生成让你一见钟情的测试报告 - 03(非常详细,非常实用)

    简介 好了,国庆假期结束,开始搬砖.为什么要把allure和jenkins集成了?原因是集成以后,我们就可以直接查看allure的结果,不需要重复输入命令.重复使用浏览器打开文件来查看allure的结 ...

  6. 针对于ECMA5Script 、ECMAScript6、TypeScript的认识

    什么是ECMAScript.什么又是ECMA? Ecma国际(Ecma International)是一家国际性会员制度的信息和电信标准组织.1994年之前,名为欧洲计算机制造商协会(European ...

  7. Django中的表关系实现及操作

    表关系的实现   预备知识 ORM的正向操作和反向操作: 1.正向操作:一个模型中定义了一个外键,通过该模型对该外键操作的操作叫做正向操作. 2.反向操作:被外键所关联的模型,通过该模型对外键所在模型 ...

  8. django-rest-framework解析请求参数

    django-rest-framework解析请求参数 前言 前面的文章中编写了接口, 调通了接口文档. 接口文档可以直接填写参数进行请求, 接下来的问题是如何接受参数, 由于请求方式与参数序列化形式 ...

  9. github代码仓库提示:“We found a potential security vulnerability in one of your dependencies”

    问题描述: Github上传代码后出现这样的错误: We found a potential security vulnerability in one of your dependencies. A ...

  10. 配置mysql可局域网内访问

    一 进入mysql输入密码 :mysql -u root -p二 执行可局域网访问命令:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ...