题目描述: Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least Common Multiple (X, Y) =b Input Input includes multiple sets of test data.Each test data occupies one line,including two positive integers a(1≤a≤2*10^…
传送门 •题意 已知 $a,b$,求满足 $x+y=a\ ,\ LCM(x,y)=b$ 条件的 $x,y$: 其中,$a,b$ 为正整数,$x,y$ 为整数: •题解 关键式子:设 $a,b$ 为正整数,如果有 $GCD(a,b)=1$,则有 $GCD(a+b,ab)=1$: 证明可以看这里[…
给大一的排位赛中数论的一题.好吧不会做...提供一个题解吧:http://blog.csdn.net/aozil_yang/article/details/53538854. 又学了一个新的公式..如果x和y互质,那么x+y和x*y互质.证明如下:随便找一个x中有的因子c,因为x,y互质,因此c不是y的因子.同时c是x*y的因子,由同余模方程知(x+y)% c = x % c + y % c = 0 + y % c.因为c不是y的因子,所以不等于0,所以c不是x+y的因子.同理可以证得x和y中的…
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1697    Accepted Submission(s): 959 Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) =…
A Simple Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1645    Accepted Submission(s): 468 Problem Description Given two positive integers a and b,find suitable X and Y to meet th…
题目链接 题意 现有\[x+y=a\\lcm(x,y)=b\]找出满足条件的正整数\(x,y\). \(a\leq 2e5,b\leq 1e9,数据组数12W\). 思路 结论 \(gcd(x,y)=gcd((x+y),lcm(x,y))\) 证明 先证\(gcd(x,y)|gcd((x+y),lcm(x,y))\) 不妨设\(gcd(x,y)=k\),则有\(k\mid x,k\mid y\),则有\(k\mid (x+y)\) -① 又\(k\mid x,x\mid lcm(x,y)\),所…
Problem Description Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least Common Multiple (X, Y) =b   Input Input includes multiple sets of test data.Each test data occupies one line,including two positive inte…
Problem Description Given two positive integers a and b,find suitable X and Y to meet the conditions:                                                        X+Y=a                                              Least Common Multiple (X, Y) =b   InputInp…
传送门 •题意 一直整数$a,b$,有 $\left\{\begin{matrix}x+y=a\\ LCM(x*y)=b \end{matrix}\right.$ 求$x,y$ •思路 解题重点:若$gcd(p,q)=1$,则$gcd(p+q,pq)=1$ 设$gcd(x,y)=g$,令$p=\frac{x}{g},q=\frac{y}{g}$,$p,q$互素 则$\left\{\begin{matrix}x+y=p*g+q*g=(p+q)g=a\\ LCM(x,y)=\frac{xy}{g}=…
http://acm.hdu.edu.cn/showproblem.php?pid=5974 遇到数学题真的跪.. 题目要求 X + Y = a lcm(X, Y) = b 设c = gcd(x, y); 那么可以表达出x和y了,就是x = i * c; y = j * c; 其中i和j是互质的. 所以lcm(x, y) = i * j * c = b 那么就得到两个方程了. i * c + j * c = a; i * j * c = b; 但是有一个c,三个未知数. 因为i和j互质,所以(i…
题目地址:HDU 1757 最终会构造矩阵了.事实上也不难,仅仅怪自己笨..= =! f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 * f(x-10) 构造的矩阵是:(我代码中构造的矩阵跟这个正好是上下颠倒过来了) |0 1 0 ......... 0|    |f0|   |f1 | |0 0 1 0 ...... 0|    |f1|   |f2 | |...................1| *  |..| = |...…
Problem Description Lele now is thinking about a simple function f(x). If x < f(x) = x. If x >= f(x) = a0 * f(x-) + a1 * f(x-) + a2 * f(x-) + …… + a9 * f(x-); And ai(<=i<=) can only be or . Now, I will give a0 ~ a9 and two positive integers k…
Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(0<=i<=9) can only be 0 or 1 . Now, I will give a0 ~ a9 and two positive in…
题目链接 题意 :给你m和k, 让你求f(k)%m.如果k<10,f(k) = k,否则 f(k) = a0 * f(k-1) + a1 * f(k-2) + a2 * f(k-3) + …… + a9 * f(k-10);思路 :先具体介绍一下矩阵快速幂吧,刚好刚刚整理了网上的资料.可以先了解一下这个是干嘛的,怎么用. 这个怎么弄出来的我就不说了,直接看链接吧,这实在不是我强项,点这儿,这儿也行 //HDU 1757 #include <iostream> #include <s…
题意:一种彩票共同拥有 N 个号码,每注包括 M 个号码,假设开出来的 M 个号码中与自己买的注有 R 个以上的同样号码,则中二等奖,问要保证中二等奖至少要买多少注(1<=R<=M<=N<=8). 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4979 -->>覆盖问题,yy可知是可反复覆盖问题,于是,DLX 上场.. N个 选 R 个,共同拥有 C[N][R] 种选法,每种选法须要被覆盖,相应于 DLX 中的列.. N个…
题意:给定a和b,求一组满足x+y=a && lcm(x, y)=b. 析:x+y = a, lcm(x, y) = b,=>x + y = a, x * y = b * k,其中 k = gcd(x, y). 然后第一个式子同时除以k,第二个式子同时除以k*k,那么x/k,和y/k是互质的,那么a/k和b/k也是互质的.所以问题就转化成了 x' + y' = a',x' * y' = b'.然后解方程并判断解的存在即可. 代码如下: #pragma comment(linker,…
题目 也是和LightOJ 1096 和LightOJ 1065 差不多的简单题目. #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int num,mod; struct matrix { ][]; }; matrix multiply(matrix x,matrix y)//矩阵乘法 { matrix temp; ;i<num;i++) { ;j<…
题意:题意很简单,不多说了. 思路: |f(10) |       |a0 a1 a2 ...a8 a9|    |f(9)|| f(9)  |       | 1   0   0 ... 0    0 |    |f(8)|| .....  |   =  | ..    ...    ...   ...    |     | ..   || f(2) |        | 0   0   0 ... 0    0|     |f(1)|| f(1) | | 0   0   0 ... 1  …
和这一题构造的矩阵的方法同样. 须要注意的是.题目中a0~a9 与矩阵相乘的顺序. #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #define N 10 using namespace std; int mod; typedef long long LL; struct matrix { LL a[10…
<font color = red , size = '4'>下列图表转载自 efreet 链接:传送门 题意:给出递推关系,求 f(k) % m 的值, 思路: 因为 k<2 * 10^9 , m < 10^5,O(n)算法应该是T掉了,当 k >= 10 时 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 * f(x-10),可以理解为这是两个行列是乘积的值,经下面分析可知用矩阵快速幂可搞 下列三个表分别命…
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757 A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6621    Accepted Submission(s): 4071 Problem Description Lele now is thin…
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2441    Accepted Submission(s): 1415 Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) =…
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 155 Accepted Submission(s): 110   Problem Description Lele now is thinking about a simple function f(x). If x < 10 f(x) = x.If…
题目 A Simple Math Problem 解析 矩阵快速幂模板题 构造矩阵 \[\begin{bmatrix}a_0&a_1&a_2&a_3&a_4&a_5&a_6&a_7&a_8&a_9\\ 1&0&0&0&0&0&0&0&0&0\\ 0&1&0&0&0&0&0&0&0&0\\ 0&…
A Simple Math Problem [题目链接]A Simple Math Problem [题目类型]矩阵快速幂 &题解: 这是一个模板题,也算是入门了吧. 推荐一个博客:点这里 跟着这个刷,应该就可以了 &代码: #include <cstdio> #include <iostream> #include <set> #include <cmath> #include <cstring> #include <al…
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been thinking about a math problem. There are N Digits, each digit is between 0 and 9. You need to use this N Digits to constitute an Integer. This Integer need…
If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);And ai(0<=i<=9) can only be 0 or 1 . Sample Input 10 9999 1 1 1 1 1 1 1 1 1 1 20 500 1 0 1 0 1 0 1 0 1 0   Sample Output 45 104 #include <iostr…
Problem Description Lele now is thinking about a simple function f(x).If x < 10 f(x) = x.If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + -- + a9 * f(x-10);And ai(0<=i<=9) can only be 0 or 1 .Now, I will give a0 ~ a9 and two positiv…
http://acm.hdu.edu.cn/showproblem.php?pid=1757 Problem Description Lele now is thinking about a simple function f(x).If x < 10  f(x) = x.If x >= 10  f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);And ai(0<=i<=9) can only be…
题意:当x < 10时, f(x) = x: 当x >= 10 时,f(x) = a0 * f(x-1) + a1 * f(x-2) +  + a2 * f(x-3) + …… + a9 * f(x-10): ai(0<=i<=9) 只能是0或者1 ,给出a0 ~ a9,k和m,计算f(k)%m(k<2*10^9 , m < 10^5). 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1757 ——>>构造矩阵…