题意:

给你的一个十进制数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【暴力】的更多相关文章

  1. CodeForces 670D1 暴力或二分

    今天,开博客,,,激动,第一次啊 嗯,,先来发水题纪念一下 D1. Magic Powder - 1   This problem is given in two versions that diff ...

  2. 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 ...

  3. Codeforces Round #439 (Div. 2) Problem A (Codeforces 869A) - 暴力

    Rock... Paper! After Karen have found the deterministic winning (losing?) strategy for rock-paper-sc ...

  4. 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 ...

  5. 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 ...

  6. codeforces 691F 暴力

    传送门:https://codeforces.com/contest/691/problem/F 题意:给你n个数和q次询问,每次询问问你有多少对ai,aj满足ai*aj>=q[i],注意 a* ...

  7. Vicious Keyboard CodeForces - 801A (暴力+模拟)

    题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的 ...

  8. (CodeForces 548B 暴力) Mike and Fun

    http://codeforces.com/problemset/problem/548/B Mike and some bears are playing a game just for fun. ...

  9. Once in a casino CodeForces - 1120B (暴力)

    大意: 给定两个字符串$a,b$, 每个字符为$0-9$, 每次操作将$a$中相邻两位加$1$或减$1$, 操作后每个数仍要为$0-9$, 求最少操作使$a$变成$b$. 先不考虑范围, 判断是否成立 ...

随机推荐

  1. 技术发展晴雨表 细数CPU接口10年变迁

    http://cpu.zol.com.cn/160/1602240_all.html#p1602240 本文导航 第1页:10年磨10剑 CPU发展突飞猛进 第2页:462与423对垒 开启CPU竞争 ...

  2. Oracle启动和关闭服务

    Oracle须要启动和关闭的服务: 1.OracleOracle_homeTNSListener     相应于数据库的监听程序 2.OracleServiceSID                 ...

  3. javascript判断一个变量或对象是否存在

    判断一个变量或对象是否存在,是一种常用的操作.我这里收集了几种. //1. 最常用的一种方法.if(typeof v == 'undefined'){ console.log("v is u ...

  4. SPOJ VLATTICE Visible Lattice Points (莫比乌斯反演基础题)

    Visible Lattice Points Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at ...

  5. 解决:Android4.3锁屏界面Emergency calls only - China Unicom与EMERGENCY CALL语义反复

    从图片中我们能够看到,这里在语义上有一定的反复,当然这是谷歌的原始设计.这个问题在博客上进行共享从表面上来看着实没有什么太大的意义,只是因为Android4.3在锁屏功能上比起老版本号做了非常大的修改 ...

  6. java的gradle项目的基本配置

    plugins { id 'org.springframework.boot' version '2.1.4.RELEASE' id 'java' } apply plugin: 'io.spring ...

  7. awk基本语法

    1 awk处理的对象 1.1 record awk处理时,默认会将文件按照换行符,分隔成record.默认分隔符是换行符. 1.2 filed 对于每个record,awk自动又分隔成filed.默认 ...

  8. (C)do{...}while(0);的用法及意义

    实际上,do{…}while(0)的作用远大于美化你的代码. 总结起来这样写主要有以下几点好处: 1. 辅助定义复杂的宏 避免引用的时候出错: 举例来说,假设你需要定义这样一个宏: #define D ...

  9. bzoj4406: [Wc2016]论战捆竹竿&&uoj#172. 【WC2016】论战捆竹竿

    第二次在bzoj跑进前十竟然是因为在UOJ卡常致死 首先这个题其实就是一个无限背包 一般做法是同余最短路,就是bzoj2118: 墨墨的等式可以拿到30分的好成绩 背包是个卷积就分治FFT优化那么下面 ...

  10. YTU 2444: C++习题 对象转换

    2444: C++习题 对象转换 时间限制: 1 Sec  内存限制: 128 MB 提交: 914  解决: 581 题目描述 定义一个Teacher(教师)类(教师号,姓名,性别,薪金)和一个St ...