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 题目大意: 给一串数 ...
随机推荐
- idea打包报错
There is insufficient memory for the Java Runtime Environment to continue.# Native memory allocation ...
- idea使用springboot的webservice基于cxf
SpringBoot整合CXF实例: 服务端构建 <dependency> <groupId>org.apache.cxf</groupId> <artifa ...
- hibernate.validator 与 jackson
1.使用hibernate.validator校验非空,在FormData类中 name字段上面加@NotEmpty @NotEmpty(message = "姓名必填") pri ...
- unity_小功能实现(碰撞检测)
1.触发器Trigger:勾选IsTrigger属性 //当player刚进入触发区域的时刻发生触发检测,比如在靠近门的某个区域门一直处于开着状态 void OnTriggerEnter(Collid ...
- eShopOnContainers部署在docker的坑
把eShopOnContainers(.net core 的版本是2.1)下载之后,部署到docker上,查看容器eShopOnContainers的项目都部署上去了. 用http://localho ...
- eslint语法规范
规则 缩进使用两个空格. eslint: indent function hello (name) { console.log('hi', name) } 1 2 3 字符串使用单引号,除 ...
- 五大典型场景中的API自动化测试实践
一.API 测试的基本步骤 通常来讲,API 测试的基本步骤主要包括以下三大步骤: 1.准备测试数据: 2.通过通用的或自己开发的API测试工具发起对被测API的request: 3.验证返回结果的r ...
- codeforces C. Sonya and Problem Wihtout a Legend(dp or 思维)
题目链接:http://codeforces.com/contest/713/problem/C 题解:这题也算是挺经典的题目了,这里附上3种解法优化程度层层递进,还有这里a[i]-i<=a[i ...
- C++中的Inline函数的使用
转载自:https://www.cnblogs.com/KellyHuang/p/4001470.html 在大多数机器上,函数调用does a lot of work:在调用函数前保存寄存器,调用结 ...
- adb命令介绍
1.adb logcat -v time -s ActivityManager:I 获取包名和activity 2. adb logcat "ActivityManager" |g ...