UVA 10976 分数拆分【暴力】】的更多相关文章

题目链接:https://vjudge.net/contest/210334#problem/C 题目大意: It is easy to see that for every fraction in the form 1 k (k > 0), we can always find two positive integers x and y, x ≥ y, such that: 1 k = 1 x + 1 y Now our question is: can you write a program…
题意: 给定正整数k(1<=k <= 10000),找出所有正整数 x>= y, 使得1/k = 1/x + 1/y 分析: 因为 x >= y 所以 1/x <= 1/y 因为 1/x + 1/y = 1/k 所以 1/k <= 2/y 即 y <= 2k 且 y >= k + 1 枚举y算出x即可 因为要避免浮点数运算, 所以可以通过1/k - 1/y  = 1/x 推出 x = (k*y)/(k-y). 那么只要k*y可以整除(k-y), x就是整数,…
题目传送门 /* 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 <…
UVA 725 题意:0~9十个数组成两个5位数(或0开头的四位数),要求两数之商等于输入的数据n.abcde/fghij=n. 思路:暴力枚举,枚举fghij的情况算出abcde判断是否符合题目条件.(注意前导零的判断) 枚举的方法为 for(int i=1234;i<=100000/n;i++){}  #include<cstdio> #include<cstring> ]; bool check(int a,int b) { memset(num,,sizeof num…
分数拆分 时间限制:3000 ms  |           内存限制:65535 KB 难度:1   描述 现在输入一个正整数k,找到所有的正整数x>=y,使得1/k=1/x+1/y.   输入 第一行输入一个整数n,代表有n组测试数据. 接下来n行每行输入一个正整数k 输出 按顺序输出对应每行的k找到所有满足条件1/k=1/x+1/y的组合 样例输入 2 2 12 样例输出 1/2=1/6+1/3 1/2=1/4+1/4 1/12=1/156+1/13 1/12=1/84+1/14 1/12…
分数拆分 时间限制:3000 ms  |  内存限制:65535 KB 难度:1   描述 现在输入一个正整数k,找到所有的正整数x>=y,使得1/k=1/x+1/y.   输入 第一行输入一个整数n,代表有n组测试数据.接下来n行每行输入一个正整数k 输出 按顺序输出对应每行的k找到所有满足条件1/k=1/x+1/y的组合 样例输入 2 2 12 样例输出 1/2=1/6+1/3 1/2=1/4+1/4 1/12=1/156+1/13 1/12=1/84+1/14 1/12=1/60+1/15…
UVA.12716 GCD XOR (暴力枚举 数论GCD) 题意分析 题意比较简单,求[1,n]范围内的整数队a,b(a<=b)的个数,使得 gcd(a,b) = a XOR b. 前置技能 XOR的性质 GCD 由于题目只给出一个n,我们要求对数,能做的也始终暴力枚举a,b,这样就有n^2的复杂度,由于n很大,根本过不了. 于是我们就想用到其中一些性质,如XOR 与GCD,不妨假设 a xor b = c,并且根据题意还知道, gcd(a,b) = c,也就说明c一定是a的因子,所以在枚举的…
UVA.10305 Maximum Product (暴力) 题意分析 直接枚举起点和重点,然后算出来存到数组里面,sort然后取最大值即可. 代码总览 #include <iostream> #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <sstream> #include <set> #inc…
题目链接:https://vjudge.net/problem/UVA-10976 It is easy to see that for every fraction in the form 1k(k > 0), we can always find two positive integers x and y, x ≥ y, such that: 1/k=1/x+1/y Now our question is: can you write a program that counts how ma…
It is easy to see that for every fraction in the form  (k > 0), we can always find two positive integers x and y,x ≥ y, such that: . Now our question is: can you write a program that counts how many such pairs of x and y there are for any givenk? Inp…