题目传送门

 /*
x>=y, 1/x <= 1/y, 因此1/k - 1/y <= 1/y, 即y <= 2*k
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f;
struct NODE
{
int x, y;
}node[MAXN]; int main(void) //UVA 10976 Fractions Again?!
{
//freopen ("UVA_10976.in", "r", stdin); int k;
while (scanf ("%d", &k) == )
{
int cnt = ;
for (int i=k+; i<=*k; ++i)
{
if ((i*k) % (i-k) == )
{
node[++cnt].x = (i*k) / (i-k);
node[cnt].y = i;
}
} printf ("%d\n", cnt);
for (int i=; i<=cnt; ++i)
{
printf ("1/%d = 1/%d + 1/%d\n", k, node[i].x, node[i].y);
}
} return ;
} /*
2
1/2 = 1/6 + 1/3
1/2 = 1/4 + 1/4
8
1/12 = 1/156 + 1/13
1/12 = 1/84 + 1/14
1/12 = 1/60 + 1/15
1/12 = 1/48 + 1/16
1/12 = 1/36 + 1/18
1/12 = 1/30 + 1/20
1/12 = 1/28 + 1/21
1/12 = 1/24 + 1/24
*/

暴力枚举 UVA 10976 Fractions Again?!的更多相关文章

  1. uva 10976 Fractions Again(简单枚举)

    10976 Fractions Again It is easy to see that for every fraction in the form 1 k (k > 0), we can a ...

  2. UVA 10976 Fractions Again?!【暴力枚举/注意推导下/分子分母分开保存】

    [题意]:给你一个数k,求所有使得1/k = 1/x + 1/y成立的x≥y的整数对. [分析]:枚举所有在区间[k+1, 2k]上的 y 即可,当 1/k - 1/y 的结果分子为1即为一组解. [ ...

  3. 暴力枚举 UVA 725 Division

    题目传送门 /* 暴力:对于每一个数都判断,是否数字全都使用过一遍 */ #include <cstdio> #include <iostream> #include < ...

  4. uva 10976 fractions again(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB3gAAAM+CAIAAAB31EfqAAAgAElEQVR4nOzdO7KtPJum69GEpAcVQQ ...

  5. Uva 10976 Fractions Again?!

    直接暴力 没技巧 y应该从k+1开始循环,因为不然y-k<0的时候 你相当于(x*y) % (负数) 了. #include <iostream> using namespace s ...

  6. UVA.10986 Fractions Again (经典暴力)

    UVA.10986 Fractions Again (经典暴力) 题意分析 同样只枚举1个,根据条件算出另外一个. 代码总览 #include <iostream> #include &l ...

  7. UVA 725 UVA 10976 简单枚举

    UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件 ...

  8. UVA.12716 GCD XOR (暴力枚举 数论GCD)

    UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 ...

  9. 分数拆分(Fractions Again?!, UVa 10976)

    题目链接:https://vjudge.net/problem/UVA-10976 It is easy to see that for every fraction in the form 1k(k ...

随机推荐

  1. VS2008+Qt+助手 智能提示不显示、Qt关键字不高亮的解决办法【已解决】

    笔者使用的开发环境是VS2008+Qt4.8.5+VAssistX,有时候会出现代码关键字不能高亮显示,并且助手的智能提示不显示.问题如下 解决的办法是在助手的选项中设置其搜索路径,助手的设置通过VS ...

  2. WPF 动画(形状、画刷)

    一:形状 在WPF用户界面中,可以通过形状(Shape)来绘制直线.椭圆.矩形及一些多边形的类.通过这些基本的图像,组合成为复杂的图形. Shape类中,主要的形状有Rectangle(),Ellip ...

  3. Android ADB命令大全(通过ADB命令查看wifi密码、MAC地址、设备信息、操作文件、查看文件、日志信息、卸载、启动和安装APK等)

    ADB很强大,记住一些ADB命令有助于提高工作效率. 获取序列号: adb get-serialno 查看连接计算机的设备: adb devices 重启机器: adb reboot 重启到bootl ...

  4. qq空间答案

    2073693795 懂得人自然会懂

  5. GIT的标准文档 使用和服务介绍

    http://www.kancloud.cn/kancloud/how-to-use-github/42192 1. 探索GitHub 熟悉Git的人几乎都知道并喜欢GitHub,反过来GitHub也 ...

  6. 经典的SQL面试题

    SQL中 inner join. left join .right join. outer join之间的区别 A表(a1,b1,c1) B表(a2,b2) a1 b1 c1 a2 b2 01 数学 ...

  7. 【leetcode】Best Time to Buy and Sell Stock III

    Best Time to Buy and Sell Stock III Say you have an array for which the ith element is the price of ...

  8. mysql5.6 timestamp

    1.timestamp 默认值 CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 在创建新记录和修改现有记录的时候都对这个数据列刷新 CURRENT_TIME ...

  9. python chm 中文帮助 (2.7 和 3.4)

    sphinx-build 生成的(htmlhelp) 存在2个问题 1.生成的html 编码 cp2152,需要修改/sphinx/builders/html.py ctx['encoding'] = ...

  10. 【JAVA、C++】LeetCode 020 Valid Parentheses

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...