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 题目大意: 给一串数 ...
随机推荐
- MinorGC 和 FullGC的理解
1.GC回收机制熟悉么,分代算法知道么?2.了解 Java 虚拟机的垃圾回收算法? 从年轻代空间(包括 Eden 和 Survivor 区域)回收内存被称为 Minor GC. Major GC 是清 ...
- IT人不仅要提升挣钱能力,更要拓展挣钱途径
前几天我上班路上,和小区门口开车的师傅闲聊,发现他们虽然学历不高,但挣钱的途径不少,比如固定接送多位客户,然后能通过朋友圈拓展新客户,而且通过客户口口相传,也能不断拉到生意,算下来每月也能挣1万5出头 ...
- Python-demo(photo)
import osimport urllib import requests#import wximport time from fake_useragent import UserAgentfrom ...
- Spring Cloud Zuul的动态路由怎样做?集成Nacos实现很简单
一.说明 网关的核心概念就是路由配置和路由规则,而作为所有请求流量的入口,在实际生产环境中为了保证高可靠和高可用,是尽量要避免重启的,所以实现动态路由是非常有必要的:本文主要介绍实现的思路,并且以Na ...
- python 05 字典
[TOC] 字典——dict { } 字典是无序,可变的数据类型. 字典:用于存储数据,存储大量数据,字典要比列表快:将数据和数据之间进行关联. 1. 定义: dic = {键:值,键:值} #每 ...
- MSIL实用指南-this的生成
C#关键字是非静态方法体内部,用Ldarg_0指代this例子ilGenerator.Emit(OpCodes.Ldarg_0);
- ES6之模块化导入导出
1.概述 在js的历史上一直没有模块(module)体系,无法将一个大程序拆分成相互依赖的小文件,再用简单的方法拼装起来,这对开发大型的.复杂的项目形成了巨大障碍. 在 ES6 之前,社区制定了一些模 ...
- javascript语言精粹数组篇之Array的方法注意事项
本文并没有详细列出Array方法详解,本文侧重点在于使用Array编程时候要注意的问题.1.Array.concat var o = {name:"Gavin"}; var a1 ...
- Delphi - cxGrid添加Footer显示
cxGrid - 添加footer显示 1:添加Footer Items 单击cxGrid Customize... ,Summary,Add: 2:添加Footer items数据绑定 选中一条需要 ...
- NLP(二十三)使用LSTM进行语言建模以预测最优词
N元模型 预测要输入的连续词,比如 如果抽取两个连续的词汇,则称之为二元模型 准备工作 数据集使用 Alice in Wonderland 将初始数据提取N-grams import nltk imp ...