题意:

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.

思路:

直接,,,

代码:

int A;
int gcd(int a,int b){
if(b==0){
return a;
}
return gcd(b,a%b);
} int calc(int base){
int ret=0;
int X=A;
while(X){
ret+=(X%base);
X/=base;
}
return ret;
}
int main(){ cin>>A;
int ans=0;
rep(i,2,A-1){
ans+=calc(i);
}
int t=gcd(ans,A-2);
printf("%d/%d\n",ans/t,(A-2)/t); return 0;
}

cf13A Numbers(,,)的更多相关文章

  1. 1120 Friend Numbers (20 分)

    1120 Friend Numbers (20 分) Two integers are called "friend numbers" if they share the same ...

  2. pat 1100 Mars Numbers(20 分)

    1100 Mars Numbers(20 分) People on Mars count their numbers with base 13: Zero on Earth is called &qu ...

  3. pat 1069 The Black Hole of Numbers(20 分)

    1069 The Black Hole of Numbers(20 分) For any 4-digit integer except the ones with all the digits bei ...

  4. pat 1023 Have Fun with Numbers(20 分)

    1023 Have Fun with Numbers(20 分) Notice that the number 123456789 is a 9-digit number consisting exa ...

  5. pat 1120 Friend Numbers(20 分)

    1120 Friend Numbers(20 分) Two integers are called "friend numbers" if they share the same ...

  6. POJ 1142 Smith Numbers(史密斯数)

    Description 题目描述 While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Leh ...

  7. UVa-11582:Colossal Fibonacci Numbers!(模算术)

    这是个开心的题目,因为既可以自己翻译,代码又好写ヾ(๑╹◡╹)ノ" The i’th Fibonacci number f(i) is recursively defined in the f ...

  8. CF D. Beautiful numbers (数位dp)

    http://codeforces.com/problemset/problem/55/D Beautiful Numbers : 这个数能整除它的全部位上非零整数.问[l,r]之间的Beautifu ...

  9. poj_1995 Raising Modulo Numbers (快速幂)

    [题目链接] http://poj.org/problem?id=1995 [算法] 基本快速幂(二进制思想) 注意两个int相乘可能溢出,加(long long)但是相乘不要加括号,不然会先溢出在类 ...

随机推荐

  1. 10.6Java学习

    1.类,对象,方法的定义.2.标识符分为两类:关键字/常见的基本类型:boolean(布尔型),byte(字节型),char(字符型),double(双精度),float(浮点),int(整型),lo ...

  2. 5cms使用sql语句给网站添加内容

    <!--list:{$Sql=UPDATE [{pre}Content] SET Indexpic="/uploadfile/201405/25/lsgjyst.jpg",t ...

  3. Probius+Kubernetes任务系统如虎添翼

    Probius是一款自定义任务引擎,可以灵活方便的处理日常运维中的各种任务,我们所有的CI/CD任务都通过Probius来完成的,这篇文章Probius:一个功能强大的自定义任务系统对其有详细的介绍, ...

  4. Java学习之随堂笔记系列——day01

    学习方法:听.问.敲.悟听:前提:上课要听懂,没有听懂可以及时的问.问:任何的问题都要及时的问.敲:重点内容.多写多练,只有写和练习才能发现新的问题,有问题就问.悟:举一反三.提升自己.今日内容:1. ...

  5. mysql允许别人通过ip访问本机mysql数据

    要想允许别人通过ip访问本机mysql数据库,首先要是本机的mysql允许别的ip访问,也就是授权:其次别人的代码里,要写对本机的ip. 一.本机mysql的授权操作 1.cmd 进入控制台 2.输入 ...

  6. nginx 利用return实现301跳转

    第一种: server { location / { rewrite ^/(.*)$ http://www.baidu.com/$1 permanent; } } 第二种: server { loca ...

  7. js正则常用方法

    <!DOCTYPE html><html><head> <meta charset="utf-8"> <title>W3 ...

  8. jmeter加密解密(解密篇)

    上一篇已经讲解了公钥加密,这篇讲解公钥解密.解密比较简单,直接操作吧. 需求是:接口中的请求体的部分参数需要先加密再请求,返回的结果中部分字段需解密. 1.在请求下新建beanshell后置处理程序, ...

  9. Python实现Telnet连接

    import loggingimport telnetlibimport timeclass TelnetClient(): def __init__(self,): self.tn = telnet ...

  10. P3335-[ZJOI2013]蚂蚁寻路【dp】

    正题 题目链接:https://www.luogu.com.cn/problem/P3335 题目大意 给出\(n\times m\)的网格,每个格子有权值.一个回路在格子的边上,要求有\(2\tim ...