这题只需要会10转P进制就行了。

PS:答案需要约分,可以直接用c++自带函数__gcd(x,y)。

洛谷网址

Codeforces网址

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 题解的更多相关文章

  1. codeforces#536题解

    CodeForces#536 A. Lunar New Year and Cross Counting Description: Lunar New Year is approaching, and ...

  2. Codeforces 840C 题解(DP+组合数学)

    题面 传送门:http://codeforces.com/problemset/problem/840/C C. On the Bench time limit per test2 seconds m ...

  3. CF55D Beautiful numbers 题解

    题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...

  4. Hdoj 1905.Pseudoprime numbers 题解

    Problem Description Fermat's theorem states that for any prime number p and for any integer a > 1 ...

  5. Hdoj 1058.Humble Numbers 题解

    Problem Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The ...

  6. codeforces 1093 题解

    12.18 update:补充了 $ F $ 题的题解 A 题: 题目保证一定有解,就可以考虑用 $ 2 $ 和 $ 3 $ 来凑出这个数 $ n $ 如果 $ n $ 是偶数,我们用 $ n / 2 ...

  7. [LeetCode] Add Two Numbers题解

    Add Two Numbers: You are given two non-empty linked lists representing two non-negative integers. Th ...

  8. poj 1995 Raising Modulo Numbers 题解

    Raising Modulo Numbers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6347   Accepted: ...

  9. CF359D:Pair of Numbers——题解

    https://vjudge.net/problem/CodeForces-359D http://codeforces.com/problemset/problem/359/D 题目大意: 给一串数 ...

随机推荐

  1. Spring-boot:多模块打包

    <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...

  2. 关于window.location.href 传中文参数 乱码问题

    传中文查询乱码问题 则需要对要传的参数进行二次编码 例如  window.location.href ="/xx.jsp?name="+name+""; 这样子 ...

  3. 消息中间件——RabbitMQ(七)高级特性全在这里!(上)

    前言 前面我们介绍了RabbitMQ的安装.各大消息中间件的对比.AMQP核心概念.管控台的使用.快速入门RabbitMQ.本章将介绍RabbitMQ的高级特性.分两篇(上/下)进行介绍. 消息如何保 ...

  4. HTTP head请求

    GET: 请求指定的页面信息,并返回实体主体. HEAD: 只请求页面的首部. POST: 请求服务器接受所指定的文档作为对所标识的URI的新的从属实体. PUT: 从客户端向服务器传送的数据取代指定 ...

  5. Linux下各目录及其作用

    目录及其作用 /:根目录,一般根目录下只存放目录,不要存放件,/etc./bin./dev./lib./sbin应该和根目录放置在一个分区中 /bin: /usr/bin: 可执行二进制文件的目录,如 ...

  6. 代码解读 | VINS 视觉前端

    本文作者是计算机视觉life公众号成员蔡量力,由于格式问题部分内容显示可能有问题,更好的阅读体验,请查看原文链接:代码解读 | VINS 视觉前端 vins前端概述 在搞清楚VINS前端之前,首先要搞 ...

  7. Ion内存的带cahce与不带cache问题分享

    一次开发中,遇到一个问题:YUV图像(由本地磁盘文件读到ION内存中)缩放时,对于缩放模块的输入源来说,使用带cache的方式要比不带cache的方式速度快数10倍. 为什么会出现这个情况呢? 在解释 ...

  8. Leetcode之二分法专题-153. 寻找旋转排序数组中的最小值(Find Minimum in Rotated Sorted Array)

    Leetcode之二分法专题-153. 寻找旋转排序数组中的最小值(Find Minimum in Rotated Sorted Array) 假设按照升序排序的数组在预先未知的某个点上进行了旋转. ...

  9. C#使用iTextSharp给PDF文件加水印

    给PDF添加水印,可以用iTextSharp. 步骤1:下载iTextSharp 步骤2:在项目中添加引用itextsharp.dll 步骤3:在程序中使用iTextSharp.text.pdf us ...

  10. Flink 源码解析 —— TaskManager 处理 SubmitJob 的过程

    TaskManager 处理 SubmitJob 的过程 https://t.zsxq.com/eu7mQZj 博客 1.Flink 从0到1学习 -- Apache Flink 介绍 2.Flink ...