![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
暴力
文章平均质量分 61
zyq_zhang
这个作者很懒,什么都没留下…
展开
-
UVa 10976
题目大意:输入整数k,找到所有正整数x>=y,使得1/k=1/x+1/y.分析:由1/k=1/x+1/y可以推得x=k*y/(y-k),我们只需要枚举即可,又因为x>=y,所以1/x所以k+1代码如下:#include#includeusing namespace std;const int maxn=10005;int x[maxn],y[maxn];int main(原创 2015-09-02 11:15:22 · 516 阅读 · 0 评论 -
UVa 725
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=666题目大意是输入一个数n,按照从大到小的顺序输出所有如abcde/fighi=n的表达式,而a----j是0---9的一个全排列,我们只需要枚举fighi即可,不到10000个数,从1234原创 2015-09-01 20:28:35 · 479 阅读 · 1 评论 -
UVa 11059
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2000因为n比较小,所以可以直接暴力。但我还是wa几次,因为少了换行,还是Cf好啊。代码:#include#include#includeusing namespace std;i原创 2015-09-01 17:37:00 · 742 阅读 · 0 评论 -
UVa 455 Periodic Strings
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=396题目大意:求一个串的最小周期。因为串很小,所以暴力可过,枚举周期即可,但是周期一定能被串的长度整除。代码:#include#include#include#include原创 2015-09-05 21:58:26 · 317 阅读 · 0 评论 -
UVa 340 Master-Mind Hints
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=276题目大意: 猜数字游戏,给定答案序列和游戏者猜测的序列,统计有多少个数字位置正确(A),有多少个数字在两个序列中都出现过但位置不对(B)。优先考虑A,而且数字只有1到9,全为0则原创 2015-09-05 13:36:54 · 417 阅读 · 0 评论 -
UVa 1225 Digit Counting
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3666题目大意就是把前N个整数12345678910111213......依次写在一起,数一数数字0到9各出现多少次。分析:因为n#include#include#inclu原创 2015-09-05 20:56:27 · 333 阅读 · 0 评论 -
凑算式
B DEFA + — + -——— = 10 C GHI这个算式中A~I代表1~9的数字,不同的字母代表不同的数字。比如:6+8/3+952/714 就是一种解法,5+3/1+972/486 是另一种解法。这个算式一共有多少种解法?(29种)暴力生成9的全排列然后去验证等式是否成立,防止精度问题。代码:// -*原创 2016-04-07 19:11:20 · 523 阅读 · 0 评论