CodeForces 13A【暴力】
题意:
给你的一个十进制数n,计算对于2~n-1进制下的每个位相加和与数n-2的比值。
思路:
n是1000,所以直接暴力一发?
#include<cstdio>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=1e5+10;
int solve(int n,int x)
{
int i;
int ans=0;
while(n)
{
i=n%x;
ans+=i;
n/=x;
}
return ans;
}
int main()
{
int n;
scanf("%d",&n);
int y=n-2;
int x=0;
for(int i=2;i<n;i++)
{
x+=solve(n,i);
}
int gcd=__gcd(x,y);
printf("%d/%d",x/gcd,y/gcd);
return 0;
}
CodeForces 13A【暴力】的更多相关文章
- CodeForces 670D1 暴力或二分
今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1 This problem is given in two versions that diff ...
- Codeforces Round #439 (Div. 2) Problem E (Codeforces 869E) - 暴力 - 随机化 - 二维树状数组 - 差分
Adieu l'ami. Koyomi is helping Oshino, an acquaintance of his, to take care of an open space around ...
- Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力
Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...
- Codeforces Round #425 (Div. 2) Problem B Petya and Exam (Codeforces 832B) - 暴力
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy ...
- Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals) Problem C (Codeforces 831C) - 暴力 - 二分法
Polycarp watched TV-show where k jury members one by one rated a participant by adding him a certain ...
- codeforces 691F 暴力
传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...
- Vicious Keyboard CodeForces - 801A (暴力+模拟)
题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的 ...
- (CodeForces 548B 暴力) Mike and Fun
http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...
- Once in a casino CodeForces - 1120B (暴力)
大意: 给定两个字符串$a,b$, 每个字符为$0-9$, 每次操作将$a$中相邻两位加$1$或减$1$, 操作后每个数仍要为$0-9$, 求最少操作使$a$变成$b$. 先不考虑范围, 判断是否成立 ...
随机推荐
- 【leetcode】 26. Remove Duplicates from Sorted Array
@requires_authorization @author johnsondu @create_time 2015.7.22 18:58 @url [remove dublicates from ...
- Andriod 从源码的角度详解View,ViewGroup的Touch事件的分发机制
转自:xiaanming的博客(http://blog.csdn.net/xiaanming/article/details/21696315) 今天这篇文章主要分析的是Android的事件分发机制, ...
- Spark MLlib Deep Learning Convolution Neural Network (深度学习-卷积神经网络)3.2
3.Spark MLlib Deep Learning Convolution Neural Network(深度学习-卷积神经网络)3.2 http://blog.csdn.net/sunbow0 ...
- 优化你的服务器Apache、MySQL、PHP
硬件上的考虑其实起50%的作用,当然是越快越好.如果不知道哪个快,就换成越贵越好.可实际上不可能做到这些,因为银子有限,所以按照这个顺序考虑:内存越大越好->硬盘SCSI好于SATA->C ...
- C# 通过比对哈希码判断两个文件内容是否相同
1.使用System.security.Cryptography.HashAlgorithm类为每个文件生成一个哈希码,然后比较两个哈希码是否一致. 2. 在比较文件内容的时候可以采用好几种方法.例如 ...
- vs2017 使用GitHub 推送到远程仓储
vs2017下使用github拓展工具无法成功推送,提示“未能推送到远程存储库” 窗口错误显示:发布到远程存储库时遇到错误: Git failed with a fatal error. HttpRe ...
- ActiveMQ(一) 转
package pfs.y2017.m11.mq.activemq.demo01; import javax.jms.Connection; import javax.jms.DeliveryMode ...
- SpringMVC框架下使用jfreechart绘制折线图,柱状图,饼状图
java代码 @Controller public class CityAction { @Autowired private CityBiz cityBiz; //柱状图 @RequestMappi ...
- Qt linux文件同步写入
因为linux 系统机制问题,文件的创建和写入并不会直接写入硬盘.而是先写入缓存,当系统要关闭或须要时才写入硬盘.为防止突然掉电,应将缓存中的文件及时同步到硬盘上去. linux 下的sync 命令具 ...
- Java Unit Testing - JUnit & TestNG
转自https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html yet another insignifican ...