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. 转:LinkedHashMap和HashMap的比较使用

    import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.uti ...

  2. pt-archiver归档数据 源库和目标库是否会出现不一致

    背景 归档的表在源库和目标库都要存在 pt-archiver归档表的场景有:不删原表数据,非批量插入目标库:不删原表数据,批量插入目标库:非批量删除原表数据,非批量插入目标库:批量删除原表数据,批量插 ...

  3. 【求赐教】VMware workstation 转VSphere

    首先我从其他电脑拷贝过来一台虚拟机(这个说法不知道准不准确,就是把所有文件夹都拷贝过来了),然后打开VMware,通过"打开虚拟机"这个操作,直接找到本地的.vmx文件,如下图所示 ...

  4. python教程 - 猿说python

    一.简介         知识改变命运,程序改变世界.互联网时代潜移默化的改变着我们的生活,伴随技术的进步,我想下一个时代应该属于人工智能和机器学习,属于python.           pytho ...

  5. eclipse快捷键——纪念我突然失忆的脑子

    常用快捷键 1.快速new出来一个对象    Alt+/ 2.快速格式化代码              Ctrl+I 3.快速导入包                     Ctrl+Shift+O

  6. JS/JQuery 禁用超链接a

    JS // 禁用超链接元素elem ; document.getElementById(elemID).setAttribute('disabled', 'disabled'); // 启用超链接元素 ...

  7. jQuery常用方法(五)-jQuery CSS

    JQuery CSS 方法说明 css( name ) 访问第一个匹配元素的样式属性. css( properties ) 把一个"名/值对"对象设置为所有匹配元素的样式属性. $ ...

  8. 什么是VR中的vection?

    Vection是VR领域的一个专有名词,其义指“在虚拟现实中给人带来‘移动’(self-motion)感觉的认知因素”1.也就是说,vection就是指那些给玩家带来“我正在这个虚拟环境中移动”这种感 ...

  9. 【MySQL】mysql5.7数据库的安装和配置

    第一步:直接从官网下载安装包,.msi 可以直接点击安装..zip直接解压到目录,本人是C:\Program Files\MySQL\mysql-5.7 第二步:需要配置环境变量,我的电脑->属 ...

  10. 谈linux服务器运维需要掌握的技能

    一.linux基础 包括对Linux整体的理解/使用和基本命令 二.运维的命令 运维相关的工具(命令) 三.基础服务 LAMP或LNMP :Apache/Nginx,MySQL,PHP/Python/ ...