Codeforces Numbers 题解
这题只需要会10转P进制就行了。
PS:答案需要约分,可以直接用c++自带函数__gcd(x,y)。
Code(C++):
- #include<bits/stdc++.h>
- using namespace std;
- int jz(int x,int p) {
- int s=,a;
- while(x>) {//10转P进制
- a=x%p;
- s+=a;//直接将算出的哪一位加上
- x/=p;
- }
- return s;
- }
- int main() {
- int A,x=;
- cin>>A;
- int y=A-;
- for(int i=;i<A;i++) {//循环从2到A-1
- int t=jz(A,i);
- x+=t;
- }
- int d=__gcd(x,y);//最大公约数函数
- x/=d;y/=d;//约分
- cout<<x<<"/"<<y<<endl;
- return ;
- }
Codeforces Numbers 题解的更多相关文章
- codeforces#536题解
CodeForces#536 A. Lunar New Year and Cross Counting Description: Lunar New Year is approaching, and ...
- Codeforces 840C 题解(DP+组合数学)
题面 传送门:http://codeforces.com/problemset/problem/840/C C. On the Bench time limit per test2 seconds m ...
- CF55D Beautiful numbers 题解
题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...
- Hdoj 1905.Pseudoprime numbers 题解
Problem Description Fermat's theorem states that for any prime number p and for any integer a > 1 ...
- Hdoj 1058.Humble Numbers 题解
Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...
- codeforces 1093 题解
12.18 update:补充了 $ F $ 题的题解 A 题: 题目保证一定有解,就可以考虑用 $ 2 $ 和 $ 3 $ 来凑出这个数 $ n $ 如果 $ n $ 是偶数,我们用 $ n / 2 ...
- [LeetCode] Add Two Numbers题解
Add Two Numbers: You are given two non-empty linked lists representing two non-negative integers. Th ...
- poj 1995 Raising Modulo Numbers 题解
Raising Modulo Numbers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6347 Accepted: ...
- CF359D:Pair of Numbers——题解
https://vjudge.net/problem/CodeForces-359D http://codeforces.com/problemset/problem/359/D 题目大意: 给一串数 ...
随机推荐
- 七缸发动机预热,docker swarm + .net core 高速飙车成功
(图片来源:Microsoft Blog) 上周五上午在我们将 .net core 博客站点由 docker swarm 自动驾驶改为 docker-compose 手动驾驶后,依然发生了翻车,意料之 ...
- 消息中间件——RabbitMQ(八)高级特性全在这里!(下)
前言 上一篇消息中间件--RabbitMQ(七)高级特性全在这里!(上)中我们介绍了消息如何保障100%的投递成功?,幂等性概念详解,在海量订单产生的业务高峰期,如何避免消息的重复消费的问题?,Con ...
- 使用node中mysql模块连接本地数据库
连接数据库的方法迄今为止学了三种: cmd方式.可视化工具,今天记第三种----node端连接数据库. 一:mysql模块介绍与下载 1.mysql模块是node端专门连接数据库的第三方模块 2.下载 ...
- 第一个Javaweb应用程序
第一个Javaweb应用程序 一.Javaweb应用程序结构 一个 web 应用程序是由一组 Servlet,HTML 页面,类,以及其它的资源组成的运行在 web 服务器上的完整的应用程序,以一种结 ...
- switch语句(下)(转载)
之前我们介绍了在switch语句中使用整数类型和枚举类型的情况.这一部分继续介绍使用string类型的情况.string类型是switch语句接受的唯一一种引用类型参数. 下面来看一段C#代码. 代码 ...
- 基本图像操作和处理(python)
基本图像操作和处理(python) PIL提供了通用的图像处理功能,以及大量的基本图像操作,如图像缩放.裁剪.旋转.颜色转换等. Matplotlib提供了强大的绘图功能,其下的pylab/pyplo ...
- 第二十四届全国青少年信息学奥林匹克联赛初赛 普及组C++语言试题
第二十四届全国青少年信息学奥林匹克联赛初赛 普及组C++语言试题 1.原题呈现 2.试题答案 3.题目解析 因博客园无法打出公式等,所以给你们几个小编推荐的链接去看看,在这里小编深感抱歉! https ...
- git@github.com: Permission denied (publickey)
1. 检查SSH key是否已经存在,如存在走第3步 : ls ~/.ssh/ 2. 如果第1步中的SSH key不存在,生成一个新的SSH key: ssh-keygen - ...
- hdu-6681 Rikka with Cake
题目链接 hdu-6681 Problem Description Rikka's birthday is on June 12th. The story of this problem happen ...
- Erlang 不同版本内容
OTP 22.0 Erlang/OTP 22是一个新的主要版本,具有新的特性和改进,同时也具有不兼容性. 要更深入地了解OTP 22发行版的亮点,您可以阅读我们的博客: http://blog.erl ...