题意:

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. CodeForce-812C Sagheer and Nubian Market(二分)

    Sagheer and Nubian Market CodeForces - 812C 题意:n个货物,每个货物基础价格是ai. 当你一共购买k个货物时,每个货物的价格为a[i]+k*i. 每个货物只 ...

  2. mysql更新数据时:当想mysql某插入有某字段设置了unique且和之前相同时,会报错,并停止运行

    这个在mysql5.7会报错: 如openid设为unique: 1062 - Duplicate entry 'oTfYq6PKne00IrcTqphmKqKnsahM' for key 'qx_w ...

  3. PHPMailer实现发送邮件的方法介绍

    来自: https://www.php.cn/php-weizijiaocheng-408762.html PHPmailer请在github下载,或者直接百度,也不难,虽然PHPmailer里面一大 ...

  4. yapi 事件创建、修改等接口事件监听

    使用的yapi作为接口文档平台.出于业务需求需要对接口创建.修改.删除等事件进行监听. yapi已经实现并预留了这个口子,但是没有找到实现的文档.这里进行简单描述下使用的方式. 一.yapi创建.修改 ...

  5. PHP-设计模式之-中介者模式

    <?php//中介者模式 -- //抽象中介者abstract class UnitedNationa{ punlic abstract function Declared($message,c ...

  6. YbtOJ#791-子集最值【三维偏序】

    正题 题目链接:http://www.ybtoj.com.cn/contest/123/problem/1 题目大意 给出\(3\)个长度为\(n\)的排列\(A,B,C\).然后一个下标集合\(S\ ...

  7. 关于Servlet

    Servlet与CGI CGI(Common Gateway Interface),早期的Web服务器技术.执行模式:将服务端的资源基于进程运行. Servlet:运行模式改为单进程多线程的形式,利用 ...

  8. CSharp委托与匿名函数

    CSharp委托与匿名函数 场景 面对事件处理,我们通常会通过定义某一个通用接口,在该接口中定义方法,然后在框架代码中,调用实现该接口的类实例的方法来实现函数的回调.可能这样来说有些抽象,那我们提供一 ...

  9. 云无关、桌面端、基于Kubernetes的平台Otomi

    一.Otomi介绍 Otomi官网:https://otomi.io/ Otomi-core核心模块Github地址:https://github.com/redkubes/otomi-core Ot ...

  10. Fikker 管理平台弱口令

    官网:www.fikker.com 应用介绍:Fikker 是一款面向 CDN/站长 的专业级网站缓存(Webcache)和反向代理服务器软件(Reverse Proxy Server). 发现过程: ...