题意:

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. jmeter5.2 性能测试 资源监控 JMeterPlugins1.4 ServerAgent2.2.1

    一.性能工具的安装部署 1.下载JMeterPlugins-Standard-1.4.0.zip的安装包 2.解压JMeterPlugins-Standard-1.4.0.zip,将其中\lib\ex ...

  2. Appium driver常用API

    click driver.find_element implicitly_wait send_keys close quit get_window_size switch_to execute bac ...

  3. shell脚本在CentOS7自动更包

    手动更包有些繁琐,就想着用脚本自动更包,后来试了下,最后成功啦! 以下是根据实际项目编写的: 操作环境:centos7.0 tomcat版本:7.0.78 以下为项目存放目录如下: updatefil ...

  4. sqlalchemy 查询结果转json个人解决方案

    参考了网上很多资料,自己搞了一个适合的 在model 内增加一个函数: class User(db.Model): __tablename__ = 'user' userid = db.Column( ...

  5. Kettle学习笔记(四)— 总结

    目录 Kettle学习笔记(一)- 环境部署及运行 Kettle学习笔记(二)- 基本操作 kettle学习笔记(三)- 定时任务的脚本执行 Kettle学习笔记(四)- 总结 Kettle中设置编码 ...

  6. NOIP 模拟 六十八

    咕了十几场了,还是写一写吧.. T1 玩水 发现满足三个人路径不同必须要有2个及以上的斜线相同结构,需要注意如果同一行或者同一列的话必须要相邻才行. #include<bits/stdc++.h ...

  7. Win32对话框模板创建的窗口上响应键消息,Tab焦点切换消息,加速键消息

    今天在学习的时候,发现对话框上不响应键盘消息,查了老半天,终于成功了,现分享出来, 1,首先要在消息循环的时候加如下代码. int WINAPI WinMain(_In_ HINSTANCE hIns ...

  8. == 和 equals区别

    == equals是两种字符串的方式 区别 == 是比较两个对象的引用地址值 equals是比较两个对象的具体内容 示例 package com.oop.demo06; public class De ...

  9. 如何基于Jupyter notebook搭建Spark集群开发环境

    摘要:本文介绍如何基于Jupyter notebook搭建Spark集群开发环境. 本文分享自华为云社区<基于Jupyter Notebook 搭建Spark集群开发环境>,作者:apr鹏 ...

  10. NOI 2021 部分题目题解

    最近几天复盘了一下NOI 2021,愈发发觉自己的愚蠢,可惜D2T3仍是不会,于是只写前面的题解 Day1 T1 可以发现,每次相当于将 \(x\to y\) 染上一种全新颜色,然后一条边是重边当且仅 ...